I found a similar solution to this question in c# How to Select all the cells in a worksheet in Excel.Range object of c#?
What is the process to do this in VBA?
I would recommend recording a macro, like found in this post;
Excel VBA macro to filter records
But if you are looking to find the end of your data and not the end of the workbook necessary, if there are not empty cells between the beginning and end of your data, I often use something like this;
R = 1
Do While Not IsEmpty(Sheets("Sheet1").Cells(R, 1))
R = R + 1
Loop
Range("A5:A" & R).Select 'This will give you a specific selection
You are left with R = to the number of the row after your data ends. This could be used for the column as well, and then you could use something like Cells(C , R).Select, if you made C the column representation.
Refering to the very first question, I am looking into the same. The result I get, recording a macro, is, starting by selecting cell A76:
Sub find_last_row()
Range("A76").Select
Range(Selection, Selection.End(xlDown)).Select
End Sub
You can simply use cells.select
to select all cells in the worksheet. You can get a valid address by saying Range(Cells.Address)
.
If you want to find the last Used Range
where you have made some formatting change or entered a value in you can call ActiveSheet.UsedRange
and select it from there. Hope that helps
you can use all cells as a object like this :
Dim x as Range
Set x = Worksheets("Sheet name").Cells
X is now a range object that contains the entire worksheet
Maybe this might work:
Sh.Range("A1", Sh.Range("A" & Rows.Count).End(xlUp))
I believe you want to find the current region of A1 and surrounding cells - not necessarily all cells on the sheet. If so - simply use... Range("A1").CurrentRegion