Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VBA and Finding the end of a column 2

Status
Not open for further replies.

warpped

MIS
Jan 19, 2000
59
US
I am using Excel to extract data from a DDE aware application. The format of the data is in CSV, and it is based on a date and time range plus the desired data fields. Because the range can vary, the amount of rows in the spreadsheet can be different. I want to then perform calculations based on a column of data. Is there any way to have VBA or a macro find the first and last row of data so I can then perform a calculation automatically? I am basically trying to use Excel to generate a daily report for users.

Thanks in advance
 
Plain finding the one and the other, assuming you want to search column A:

Sub FindRows()
x = Range("A1").End(xlDown).Row
MsgBox x 'first row
x = Selection.SpecialCells(xlCellTypeLastCell).Row
MsgBox x 'last row
End Sub

Combined to select the range:

Sub SelectRows()
x = Range("A1").End(xlDown).Row
y = Selection.SpecialCells(xlCellTypeLastCell).Row
Range(Cells(x, 1), Cells(y, 1)).Select
End Sub

Various other ways for the selection thing, though.

IS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top