Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I am fairly new to Excel VBA and I need to know how to loop through used rows in a one column. In logic for each row in column A starting @ A4 to A whatever So I need to return values in A4-A whatever is used. I hope that makes sense Thanks! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() For Each cell in Range(Range("A4"), Range("A4").End(xlDown)) do something with cell Next cell -- HTH Bob "Gsurfdude" wrote in message ... Hello, I am fairly new to Excel VBA and I need to know how to loop through used rows in a one column. In logic for each row in column A starting @ A4 to A whatever So I need to return values in A4-A whatever is used. I hope that makes sense Thanks! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Try this Sub marine() Dim LastCol as Long lastcol = ActiveSheet.Cells(4, Columns.Count).End(xlToLeft).Column Set myrange = Range(Cells(4, 1), Cells(4, lastcol)) For Each c In myrange 'Do Things Next End Sub -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "Gsurfdude" wrote: Hello, I am fairly new to Excel VBA and I need to know how to loop through used rows in a one column. In logic for each row in column A starting @ A4 to A whatever So I need to return values in A4-A whatever is used. I hope that makes sense Thanks! |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ignore my post I read it as last used column in a row
-- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "Mike H" wrote: Hi, Try this Sub marine() Dim LastCol as Long lastcol = ActiveSheet.Cells(4, Columns.Count).End(xlToLeft).Column Set myrange = Range(Cells(4, 1), Cells(4, lastcol)) For Each c In myrange 'Do Things Next End Sub -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "Gsurfdude" wrote: Hello, I am fairly new to Excel VBA and I need to know how to loop through used rows in a one column. In logic for each row in column A starting @ A4 to A whatever So I need to return values in A4-A whatever is used. I hope that makes sense Thanks! |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I like to start at the bottom and look up to find that last used cell. It's
useful if the range could contain empty cells. Dim myRng as range dim myCell as range with worksheets("Somesheetnamehere") set myrng = .range("A4", .cells(.rows.count,"A").end(xlup)) end with for each mycell in myrng.cells msgbox mycell.address 'or whatever you want to do next mycell Gsurfdude wrote: Hello, I am fairly new to Excel VBA and I need to know how to loop through used rows in a one column. In logic for each row in column A starting @ A4 to A whatever So I need to return values in A4-A whatever is used. I hope that makes sense Thanks! -- Dave Peterson |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Where did you want these values returned to... a VB array, a range, a comma
delimited string, somewhere else? -- Rick (MVP - Excel) "Gsurfdude" wrote in message ... Hello, I am fairly new to Excel VBA and I need to know how to loop through used rows in a one column. In logic for each row in column A starting @ A4 to A whatever So I need to return values in A4-A whatever is used. I hope that makes sense Thanks! |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Oh, and when you say "values"... do you mean numbers or text? If text, will
there ever be spaces in the text? I ask this because if the answer is either "numbers" or "text without spaces", then I think there is a more efficient way to get to the values than looping through the cells. -- Rick (MVP - Excel) "Rick Rothstein" wrote in message ... Where did you want these values returned to... a VB array, a range, a comma delimited string, somewhere else? -- Rick (MVP - Excel) "Gsurfdude" wrote in message ... Hello, I am fairly new to Excel VBA and I need to know how to loop through used rows in a one column. In logic for each row in column A starting @ A4 to A whatever So I need to return values in A4-A whatever is used. I hope that makes sense Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I create a loop to merge contents of rows 1-4 across column | Excel Programming | |||
loop thru column and highlight the rows | Excel Discussion (Misc queries) | |||
Loop every 26 rows and if.. | Excel Programming | |||
Loop through column headers to search from column name and get cell range | Excel Programming | |||
Cannot loop through rows in C# | Excel Programming |