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

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

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

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
Identifying the every nth document in a column boby Excel Discussion (Misc queries) 2 May 4th 09 10:33 PM
Identifying Last Column With Text stan Excel Discussion (Misc queries) 1 February 5th 09 02:58 PM
Identifying the row and column of a table value JHB Excel Discussion (Misc queries) 6 January 28th 09 10:17 PM
Identifying duplicate content in column excelstart[_3_] Excel Programming 3 January 9th 06 10:22 PM


All times are GMT +1. The time now is 11:41 PM.

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"