SpecialCells method to find Last Used Column in worksheet


Sub LastUsedColumn_SpecialCells_1()

Dim lastColumn As Integer

lastColumn = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Column

MsgBox lastColumn

End Sub



Sub LastUsedColumn_SpecialCells_2()

Dim lastColumn As Integer

lastColumn = ActiveSheet.Range("A1").SpecialCells(xlCellTypeLastCell).Column

MsgBox lastColumn

End Sub

Comments

Popular posts from this blog

50 Excel VBA Oral Interview Questions