Doing a LOOP for multiple columns, help please...

  • Thread starter Thread starter jhong
  • Start date Start date
J

jhong

Hi,

Any suggestion would be of great help. I am doing a macro that will
lookup values from another sheet. Here's the scenario, from column B,
it will look up data from column A. My report is up to column Z, how
can I make a loop that will run from column B up to column Z.

What I did is I created a loop for each column, which is quite long. I
hope you have a better way in your mind :-)

Thanks in Advance!


Jerome
 
Use cells instead of Range of along with Range.

for ColCount = 1 to 26
cells(1,i).copy
next ColCount

or

for ColCount = 1 to 26
range(cells(1,i),cells(10,i)).copy
next ColCount

or

for ColCount = 1 to 26
Columns(i).copy
next ColCount
 
Hi
First sentence talks about two sheets. Second sentence does not
mention two sheets. Third sentence does not mention two sheets and
introduces a Report. What are we looking at, and where are we looking
at it from???
regards
Paul
 
Hi,

Thanks for the reply! I'm just a newbie with vba macro, i've tried but
i cannot incorporate your suggestion with my code, hope you can take a
look with my code and check how can it be done.

Private Sub Test()

Sheets("Sheet1l").Select

Range("B12").Select

Do Until Selection.Formula = ""

ActiveCell.FormulaR1C1 = "='Sheet1'!RC+'Sheet2'!RC"

Selection.Offset(1, 0).Select

Loop


End Sub


I want this macro to run up to column Z, dont know how to do it :-(


Thanks in advance!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top