There are different ways to find last row or column which is populated.
Last used row
Find last row from bottom up
lastRow = sheet.Cells(Rows.Count, 1).End(xlUp).Row
Find last row from top down
lastRow = sheet.Cells(1, 3).End(xlDown).Row
Last used column
From right to left
lastColumn = sheet.Cells(1, sheet.Columns.Count).End(xlToLeft).Column
From left to right
lastColumn = sheet.Range("A1").CurrentRegion.Columns.Count
Source
https://www.thespreadsheetguru.com/blog/2014/7/7/5-different-ways-to-find-the-last-row-or-last-column-using-vba