![]() |
identifying the end of a data column
If I want to loop through a column of data, I have usually stated the range (A1:A10). How do I do this without stating the range, but instead have the loop run in a given column until the first empty cell? kind regadrs, Matt |
identifying the end of a data column
How about
For each C in Activesheet.usedRange.Columns("A").cells if C.Value="" Then exit For ' This might be redundant .... doing whatever to C.Value Next C -- Shorter programs last longer! "MJKelly" wrote: If I want to loop through a column of data, I have usually stated the range (A1:A10). How do I do this without stating the range, but instead have the loop run in a given column until the first empty cell? kind regadrs, Matt |
identifying the end of a data column
I think you meant find the last row of data:
lRow = Range("A65536").End(xlUp).Row -- Dan On Feb 12, 8:51*am, MJKelly wrote: If I want to loop through a column of data, I have usually stated the range (A1:A10). *How do I do this without stating the range, but instead have the loop run in a given column until the first empty cell? kind regadrs, Matt |
identifying the end of a data column
One common way is this
Sub stance() Dim myrnge As Range lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row Set myrange = Range("A1:A" & lastrow) For Each c In myrange 'do somthing Next End Sub Or another to loop down Column A Sub stance1() x = 1 Do myvalue = Range("A" & x).Value 'do something x = x + 1 Loop Until myvalue = "" End Sub Mike "MJKelly" wrote: If I want to loop through a column of data, I have usually stated the range (A1:A10). How do I do this without stating the range, but instead have the loop run in a given column until the first empty cell? kind regadrs, Matt |
All times are GMT +1. The time now is 05:43 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com