Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Freeman
 
Posts: n/a
Default Looping in VB with cell ranges

I have a function that brings in four different cell ranges:
ie: Total(AccountRange As Range, DateRange As Range, etc...)

Within the VB function I have a For/Next Loop as follows:
ie: For Each cell in AccountRange
"multiple if statements"
Next cell

I want to increment the rows in the other cell ranges during the looping
process. When the AccountRange row increases during the "Next cell" call
then I want the other ranges to follow suit.

By the way what actually happens during the looping process for a range of
cells? If the range is 2 columns by 4 rows does the "Next cell" call go down
the rows then jump to the top of the 2nd column and again proceed down the
rows??
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default Looping in VB with cell ranges


"Freeman" wrote in message
...
I have a function that brings in four different cell ranges:
ie: Total(AccountRange As Range, DateRange As Range, etc...)

Within the VB function I have a For/Next Loop as follows:
ie: For Each cell in AccountRange
"multiple if statements"
Next cell

I want to increment the rows in the other cell ranges during the looping
process. When the AccountRange row increases during the "Next cell" call
then I want the other ranges to follow suit.


What exactly do you mean? You can get the row by simply using

cell.Row

but I am not clear as to what you mane by increment the rows in the other
cell ranges.

By the way what actually happens during the looping process for a range of
cells? If the range is 2 columns by 4 rows does the "Next cell" call go

down
the rows then jump to the top of the 2nd column and again proceed down the
rows??


No, other way. It goes across the columns, then down to the first column of
the next row.


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default Looping in VB with cell ranges

BTW, you can force it down the rows, then next column with

For Each cell in Application.Transpose(rng)

but you are not working with a range object now, but an array of values.

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Freeman" wrote in message
...
I have a function that brings in four different cell ranges:
ie: Total(AccountRange As Range, DateRange As Range, etc...)

Within the VB function I have a For/Next Loop as follows:
ie: For Each cell in AccountRange
"multiple if statements"
Next cell

I want to increment the rows in the other cell ranges during the looping
process. When the AccountRange row increases during the "Next cell" call
then I want the other ranges to follow suit.

By the way what actually happens during the looping process for a range of
cells? If the range is 2 columns by 4 rows does the "Next cell" call go

down
the rows then jump to the top of the 2nd column and again proceed down the
rows??



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
Instead of a negative number, I'd like to show zero... Dr. Darrell Excel Worksheet Functions 6 December 7th 05 08:21 PM
Transfer Cell Formatting for linked cells Scott Excel Discussion (Misc queries) 2 November 23rd 05 11:04 PM
How cell ranges are handled by worksheet functions/row column matc Martin Excel Worksheet Functions 1 September 30th 05 01:51 PM
copying cell names Al Excel Discussion (Misc queries) 12 August 11th 05 03:01 PM
Possible Lookup Table Karen Excel Worksheet Functions 5 June 8th 05 09:43 PM


All times are GMT +1. The time now is 10:03 PM.

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

About Us

"It's about Microsoft Excel"