Try:
Sub last_row()
'Dim lastrow As Range
Sheets("sheet1").Select
lastrow = Range("g3:m3").End(xlDown).Row - 1
Range("G3:M" & lastrow).Select
End Sub
Changes made are:
1.The name of the sub; you named the sub the same as a variable name.
2.The commenting out of the Dim line; you defined lastrow as a range
then you try 2 lines later to assign a number to it. You don't need
it.
3.Changed
Range("g3" & lastrow).Select
to
Range("G3:M" & lastrow).Select
You could tweak it a bit more by changing the line:
lastrow = Range("g3:m3").End(xlDown).Row - 1
to
lastrow = Range("g3").End(xlDown).Row - 1
since xl won't look in multiple columns for the last cell, only one,
the active cell column. Replace the G of G3 with the column letter of
the column you want to find the last entry of.