Hello
I am struggling to select a variable range based on the second row and last row. All I want is to select the entire rows between the variable second row till the last row. And then I want to sort them. I am able to define the last row easy which is quiet straightforward. And I am also able to define the second row easy. Now the issue when i want to select the range between the two (For the entire rows), it doesn't allow me to. Is there a way for this. I have used
. Also I have used
. They both don't work.
So i have provided the simple code i used. Everything is going fine till the last line of the code to be able to select.
Ideally i know if you want to select entire rows for example from row 4 to row 10, you write
and that works but when it is variable rows that i want to select, I can't seem to do it.
Any help would be really appreciated as I am really struggling with this simple task. Thanks alot.
I am struggling to select a variable range based on the second row and last row. All I want is to select the entire rows between the variable second row till the last row. And then I want to sort them. I am able to define the last row easy which is quiet straightforward. And I am also able to define the second row easy. Now the issue when i want to select the range between the two (For the entire rows), it doesn't allow me to. Is there a way for this. I have used
Code:
Range("FirstRow:FinalRow")
Code:
Rows("Firstrow:Finalrow")
So i have provided the simple code i used. Everything is going fine till the last line of the code to be able to select.
Ideally i know if you want to select entire rows for example from row 4 to row 10, you write
Code:
Rows("4:10").Select
Any help would be really appreciated as I am really struggling with this simple task. Thanks alot.
Code:
Sub Variablerange()
Dim finalrow As Long
Dim mysheet As Worksheet
Dim myworkbook As Workbook
Dim FirstRow As Long
Dim secondrow As Long
FirstRow = ActiveCell.End(xlUp).Offset(1, 0).Row
Finalrow = mysheet.Cells(Rows.Count, 1).End(xlUp).Row
Rows("Firstrow:lastrow").select
End Sub