I have written a simple code to illustrate my predicament.
Sub test()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets(\"Sheet1\")
Dim k As Lon
That is nice question :)
When you have situation with 1 cell (A1), it is important to identify if second declared cell is not empty (sh.Range("A1").End(xlDown)
). If it is true it means your range got out of control :) Look at code below:
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Arkusz1")
Dim k As Long
If IsEmpty(sh.Range("A1").End(xlDown)) = True Then
k = 1
Else
k = sh.Range("A1", sh.Range("A1").End(xlDown)).Rows.Count
End If