z = ThisWorkbook.Sheets("SampleResult").Cells(Rows.count, 1).End(xlDown).Offset(-4, 0).row
That says to start with row 1048576, go to the end (still 1048576), and then go up 4 rows ( 1048572)
The usual way is to start at the last row and go up (note the With and the dots)
Sub test()
Dim z As Long
With Sheets("SampleResult")
z = .Cells(.Rows.Count, 1).End(xlUp).Row - 4
End With
MsgBox z
End Sub
Although if you want the last 4 rows, you'd use -3 (not .Offset (-4,0) since that will give you row 22, 23, 24, and 25 in my test
Capture.JPG