Looping until empty column

T

theguz

Here is my dilemma. I can do VBA in Access, but for some reason I jus
don't get it in excel. What I want to do is go down a column and stor
that info in a variable. I want this to happen untill there is no mor
data. Once I have that data I want to go to another page and store th
data in an empty column. I want the program to auto. find the empt
column. Thank You in advance.
thegu
 
D

Duke Carey

Are you going to copy EVERYTHING in the column, i.e., are you starting with
row 1 and moving down until you find nothing else?

If so, just copy the column

Now, what's the criteria for finding an empty column? Is it the first
column you come to, moving left to right, that has nothing in it? I'll
assume that's so.

This code copies column A on sheet1 to the first unused column on sheet2

Dim src As Range
Dim tgt As Range

Set src = Worksheets("sheet1").Range("A:A")
With Worksheets("sheet2")
Set tgt = .UsedRange.Offset(0, .UsedRange.Columns.Count). _
Resize(1, 1).EntireColumn
End With
src.Copy tgt
 
Top