[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6941
  • Last Modified:

Excel VBA Syntax (Column Copy Between Worksheets)

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
cdromes
Asked:
cdromes
2 Solutions
 
Wayne Taylor (webtubbs)Commented:
Hi Jason,

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

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

Regards,

Wayne
0
 
RayData AnalystCommented:
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
 
cdromesAuthor Commented:
Thanks to both for the answers!

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

Jason
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now