Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looping thru values in a Range of Cells
Hi All
We have a requirement whereby we would like to loop-thru range of cells, read the values from these cell range and then do certain action. For example, we will define list of values in a column say C5:C25 ......D5:D25; see example below --------------------------- C D --------------------------- 5 AgentID 10 6 Agentname 25 7 Address 20 ........ What we would like to do is 1. Read the Cells one by one starting [C5 and D5] , then [C6 and D6] and then [C7 and D7]... 2. The value in C5 will be the Column in Pivot table The value in D5 will be the Column Length for that column 3. Repeat the same (in-loop) for C6 and D6......... C25 and D25 4. The only catch is, the MAX range is un-predictable, it could be C5 - C10 for one report and C5-C15 for others. Is this in any way achieveable? I know we can give some "Virtual Name" for the cells of the excel, not sure if I can do that for range of Cells. Thanks Prasanna |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looping thru values in a Range of Cells
Is this any help...? LastRow = Range("C5").End(xlDown).Row For i = 5 To LastRow ColumnNr = Range("C" & i).Value ColumnLn = Range("D" & i).Value Next -- Kaa ----------------------------------------------------------------------- Kaak's Profile: http://www.excelforum.com/member.php...nfo&userid=751 View this thread: http://www.excelforum.com/showthread.php?threadid=39121 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looping thru values in a Range of Cells
Hi Kaak
What you said is defenitely helping me. But ".End(xlDown)" cannnot suffice my requirement 100%. The problem we have is as follows" Row 5-25 will be for Group-1, Row # 26 will be some "Header Row", 27-35 may be Data for Group-2....; I short data can go up as many rows as we want and which are then logically split into groups within it. Each group of Data goes in different section of the PIVOT Table. The below picture might explain what I'm saying. --------------------------- C D --------------------------- Row 5-25 is Data for Group1 5 AgentID 10 6 Agentname 25 7 Address 20 ........ 25 ---------------------------------------------------------- 26 Some Header to distinguish the Group(s) --------------------------- Row 27-35 is Data for Group2 27 PoNumber 10 28 PODate 15 29 ShipToAddress 50 ........ 35 ....... What I want is 2 while loops, first one from Row 5 - Row 25, second one from Row 27 - Row 35. Though I have trold you the exact row numbers now, it wont be true always, the row numbers can be more or less (it's dynamically changing from report to report). Hope this explains Thanks PP "Kaak" wrote: Is this any help...? LastRow = Range("C5").End(xlDown).Row For i = 5 To LastRow ColumnNr = Range("C" & i).Value ColumnLn = Range("D" & i).Value Next i -- Kaak ------------------------------------------------------------------------ Kaak's Profile: http://www.excelforum.com/member.php...fo&userid=7513 View this thread: http://www.excelforum.com/showthread...hreadid=391214 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Looping thru a range of cells | New Users to Excel | |||
looping through an giving values to cells in vba | Excel Discussion (Misc queries) | |||
Looping through a range of cells | Excel Programming | |||
Looping thru cells in a named range | Excel Programming | |||
looping cells though a named range | Excel Programming |