?
Solved

Excel VBA Syntax (Column Copy Between Worksheets)

Posted on 2007-03-20
3
Medium Priority
?
6,933 Views
Last Modified: 2013-12-26
Howdy

I have 12 worksheets, each with 11 columns of data that I need to transfer into 11 other worksheets, one collumn at a time.  The pseudocode below sort of shows what I'm trying to do, but I'm light on the syntax specifics involved with VBA.  

for h = 1 to 12
   for i = 1 to 11
      for j = 1 to worksheet(h).Coumn(i).#ofRows
         copy all values from worksheet(h).Column(i).Row(j).value to worksheet13.Column(i).Row(j).value
         ....
         ....
         copy all values from worksheet(h).Column(i).Row(j).value to worksheet23.Column(i).Row(j).value
      end
   end
end

My big question is whether or not it's possible to just move an entire column in one command or whether it's necessary to move each value at a time.  That would only save me a single FOR loop, but complexity is complexity....the less complex the algorithm, the happier the gods tend to be.  

Any help would be, as always, greatly appreciated.

Jason
0
Comment
Question by:cdromes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 100 total points
ID: 18760491
Hi Jason,

It's possible to copy an entire column. Like this....

    Worksheets(h).Column(i).Copy worksheet13.Column(i)

Regards,

Wayne
0
 
LVL 11

Assisted Solution

by:Ray
Ray earned 100 total points
ID: 18763943
Jason,

Not directly an answer, but . . .

Anytime your are "light" on syntax, just create a macro.  Use the record a macro feature to do what you want, then look at the code that was created and use it/ change it as you see fit.  This single tip will get you MANY, MANY Miles of value!  (at least it has for me).

good luck!
0
 

Author Comment

by:cdromes
ID: 18764389
Thanks to both for the answers!

rlistenb, that's so simple and handy that it's genius.  GENIUS!  

Jason
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question