ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Doing a LOOP for multiple columns, help please... (https://www.excelbanter.com/excel-programming/405653-doing-loop-multiple-columns-help-please.html)

jhong

Doing a LOOP for multiple columns, help please...
 
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

joel

Doing a LOOP for multiple columns, help please...
 
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




"jhong" wrote:

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


[email protected]

Doing a LOOP for multiple columns, help please...
 
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

On Feb 6, 9:29*am, jhong wrote:
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



jhong

Doing a LOOP for multiple columns, help please...
 
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!!


On Feb 6, 7:21*pm, Joel wrote:
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



"jhong" wrote:
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- Hide quoted text -


- Show quoted text -




All times are GMT +1. The time now is 01:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com