I\'d like to select to the bottom of the worksheet, but not below what is used/stored. I might have 10,000 rows, but I certainly don\'t have 65,536. I won\'t know ahead of
This function returns no of max row and max column in the worksheet with some content. maybe it will be usefull for sbdy. of course this is very slow, but usually we don't have to check all the rows and columns so one have to adjust the loops.
Public Function content_area(shName As String) As Variant
Dim res(1 To 2) As Integer
Dim ark As Worksheet
Set ark = ThisWorkbook.Sheets(shName)
nCol = 0
nRow = 0
For i = 1 To ark.Columns.Count
temp = ark.Cells(ark.Cells(1, i).EntireColumn.Rows.Count, i).End(xlUp).Row
If temp > nCol Then nCol = temp
Next
For i = 1 To ark.Rows.Count
temp = ark.Cells(i, ark.Cells(i, 1).EntireRow.Columns.Count).End(xlToLeft).Column
If temp > nRow Then nRow = temp
Next
res(1) = nCol
res(2) = nRow
content_area = res
End Function