
Row: " & lastCell.Row & ", Column: " & lastCell.Columnįirst Cell in UsedRange Row: 2, Column: 2 Row: " & firstCell.Row & ", Column: " & firstCell.Columnĭebug.Print "Last Cell in UsedRange. Set lastCell = ws.UsedRange.Cells(ws., ws.)ĭebug.Print "First Cell in UsedRange.
#Multiple subtotals in excel 2010 using vba code
Use the code below to check the area of the UsedRange in VBA:ĭim lastCell As Range, firstCell As Range, ws As Worksheet If you want to know more about reducing Excel file size read my post Check UsedRange in VBA Often bloated, large Excel files are effects of misuse of UsedRange. The UsedRange constantly expands the moment you modify in any way a cell outside of the previously Used Range of your Worksheet. The VBA UsedRange represents the area reserved and saved by Excel as the currently used Range on and Excel Worksheet. Set lastCell = ws.UsedRange.Cells(ws.,ws.) To get the Last Cell in the Worksheet UsedRange we need to use the UsedRange property of an VBA Worksheet. 'Get Last Cell with Data in Worksheet using Find Set lastCell = ws.Cells.SpecialCells(xlCellTypeLastCell) 'Get Last Cell with Data in Worksheet using SpecialCells To get the Last Cell with data in a Worksheet we need to use the SpecialCells or Find properties of an Excel VBA Range. Set lastCell = Range("A1").End(xlRight).End(xlDown)ĭebug.Print "Row: " & lastCell.row & ", Column: " & lumn
#Multiple subtotals in excel 2010 using vba series
To get the Last Cell in a series of data (table with non-blank values) we need to use the End property of an Excel VBA Range. Set lastColumn = ws.UsedRange.Columns(ws.).EntireColumn To get the Last Column in the Worksheet UsedRange we need to use the UsedRange property of an VBA Worksheet.ĭebug.Print ws.UsedRange.Columns(ws.).Column Set lastColumn = Debug.Print ws.Cells.Find(What:="*", _

'Get Last Column with Data in Worksheet using Find

Set lastColumn = ws.Cells.SpecialCells(xlCellTypeLastCell).EntireColumn 'Get Last Column with Data in Worksheet using SpecialCellsĭebug.Print ws.Cells.SpecialCells(xlCellTypeLastCell).Column To get the Last Column with data in a Worksheet we need to use the SpecialCells or Find properties of an Excel VBA Range. Last Column with Data in a Row Last Column with Data in a Worksheet The Last Column may as be interpreted as: This last cell does not need to have any values or formulas as long as it was edited or formatted in any point in time VBA Last Column The Used Range starts at the first used cell and ends with the most right, down cell that is used by Excel.

The UsedRange represents a Range used by an Excel Worksheet. Set lastRow = ws.UsedRange.Rows(ws.).EntireRow To get the Last Row in the Worksheet UsedRange we need to use the UsedRange property of an VBA Worksheet.ĭebug.Print ws.UsedRange.Rows(ws.).Row Set lastRow = Debug.Print ws.Cells.Find(What:="*", _ 'Get Last Row with Data in Worksheet using Findĭebug.Print Debug.Print ws.Cells.Find(What:="*", _ Set lastRow = ws.Cells.SpecialCells(xlCellTypeLastCell).EntireRow 'Get Last Row with Data in Worksheet using SpecialCellsĭebug.Print ws.Cells.SpecialCells(xlCellTypeLastCell).Row To get the Last Row with data in a Worksheet we need to use the SpecialCells or Find properties of an Excel VBA Range. Set lastRow = Range("A1").End(xlDown).EntireRow To get the Last Row with data in a Column we need to use the End property of an Excel VBA Range.ĭebug.Print Range("A1").End(xlDown).Row 'Result: 5
