I have a piece of code which selects the entire row from my table based on the last data in column K. E.g. if I have rows 5 to 10 populated, it will select row 10.
How do I get the code to select multiple rows from row 5 all the way to the last row as defined below?
Thanks
Sub selectlastrow()
Dim lastrow As Long
Dim report As Worksheet
Set report = Excel.ActiveSheet
Sheets("Risks").Select
lastrow = Range("K5:K48").End(xlDown).Row
report.Cells(lastrow, 2).EntireRow.Select
End Sub
To follow up:
I'm stuck on how to structure a piece of code that:
- Loops through all worksheets that begin with the number 673: (e.g. 673:green, 673:blue)
Selects the data in these worksheets from row 5 up until the last row with data - code that works for this is
With report .Range(.Cells(5, "K"), .Cells(.Rows.Count, "K").End(xlUp)).EntireRow.Select End With
- Select the "Colours" worksheet
- Paste the rows at the next available blank row. There could be up to 40/50 worksheets which will have data pasted into the "Colours" worksheet so I need the data added to the next available line.
Thank you in advance.