Ways to find Last Row & Last Column of a excel worksheet (VBA)

1) Current Region

dim lrow as integer, lcol as integer

Last Row

lrow=range("a1").currentregion.rows.count

Last Column

lcol=range("a1").currentregion.columns.count

2) Last Row

dim lrow as interger

a) lrow=cells.find(what:="*", searchorder:=xlbyrows, searchdirection:=xlprevious).row

b) lrow=cells(rows.count,1).end(xlup).row

3) Last Column

dim lcol as integer

a) lcol=cells.find(what:="*", searchorder:=xlbycolumns, searchdirection:=xlprevious).column

b) lcol=cells(1,columns.count).end(xltoleft).column


Comments

Popular posts from this blog

Power Automate - Automatically fetch data from Power BI in to Excel and Send the copy of the Excel file via Email

Separate Text (Characters) & Numbers from Alpha Numeric String Using Formula and Macro (VBA)

File System Object