Macro to read to end of column list

J

joe kristofeld

I know this is simple but I don't have a resource for commands such as "end
down",etc.

anyways, if I want a macro to include only the data I've entered and have it
know that by reading "end down" then execute a macro. What's the command for
having the maco include all data in the column without having me identify
the length of the column rows?
gracias....

example:
column data:
1
2
3
4

If I want a macro to read each of these rows to include in a macro command,
what is the "code"?

--


---------------------------------------------------------------------
"Are you still wasting your time with spam?...
There is a solution!"

Protected by GIANT Company's Spam Inspector
The most powerful anti-spam software available.
http://mail.spaminspector.com
 
D

Don Guillett

try this to select a1:a to last column
Sub thedatarow()
x = Cells(1, "IV").End(xlToLeft).Column
Range(Cells(1, 1), Cells(1, x)).Select
End Sub
 
B

Bernie Deitrick

Don,

I think he wants the rows.

Joe,

Range("A1",Range("A1").End(xlDown)).Select

will select the contiguous cells starting in A1.

HTH,
Bernie
MS Excel MVP
 
D

Don Guillett

Bernie, Thanks. I mis-read.

Bernie Deitrick said:
Don,

I think he wants the rows.

Joe,

Range("A1",Range("A1").End(xlDown)).Select

will select the contiguous cells starting in A1.

HTH,
Bernie
MS Excel MVP
 
M

May

When I have information that changes lengths I usually do
is Find my firstrow and then find my lastrow and then
execute the command I want by using:

Option Explicit
Dim LASTROW, FIRSTROW As Integer

Sub test

'find firstrow - this will do a find in column A for -
Column data- and then use that row number. Since you
would want it to start on the line below this line you
would put +1 after Firstrow
FIRSTROW = Application.Match(column data, Range("A:A"), 0)

'find lastrow - this will find the last row on your entire
spreadsheet
If WorksheetFunction.CountA(Cells) > 0 Then
LASTROW = Cells.Find(What:="*", After:=[a1],
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row

Rows(FIRSTROW + 1 & ":" & LASTROW).select

End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top