Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default 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 -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
loop through columns (using for-loop) Kurt[_3_] Excel Programming 2 November 23rd 07 08:56 PM
Loop through Columns Sally[_6_] Excel Programming 3 August 26th 06 10:52 AM
loop over columns kizzie Excel Discussion (Misc queries) 4 August 10th 05 01:31 PM
loop through columns hotherps[_78_] Excel Programming 6 July 23rd 04 11:40 AM
Loop 20 columns Help! Michael168[_106_] Excel Programming 2 July 2nd 04 12:26 PM


All times are GMT +1. The time now is 10:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"