Excel Macro - Dynamic Column Selection
Solved/Closed
kunalp
Posts
1
Registration date
Tuesday December 9, 2008
Status
Member
Last seen
December 9, 2008
-
Dec 9, 2008 at 10:59 PM
maggie - Mar 4, 2010 at 10:24 PM
maggie - Mar 4, 2010 at 10:24 PM
Related:
- Excel Macro - Dynamic Column Selection
- Spell number in excel without macro - Guide
- Excel marksheet - Guide
- Excel free download - Download - Spreadsheets
- Macros in excel download - Download - Spreadsheets
- How to take screenshot of selected area in excel - Guide
2 responses
I have created something like this.
Consider this:
The last row of the spreadsheet should have values 1 & 0. make a sweep through the bottom row, select all 1s and hide all 0s.
If you need more help on code, reply.
Consider this:
The last row of the spreadsheet should have values 1 & 0. make a sweep through the bottom row, select all 1s and hide all 0s.
If you need more help on code, reply.
' Determining datasheet range.
Dim lngLastRow As Long
Dim lngLastCol As Long
Dim varDataSelect As Variant
' Select rows and columns range dynamically.
Selection.End(xlDown).Select
lngLastRowNum = ActiveCell.Row
Selection.End(xlToRight).Select
lngLastCol = ActiveCell.Column
'Name of worksheet "MonthlyReceivedClaims_Data" start at Row 1 Column 1
'and end at ":R" & lngLastRowNum & "C" & lngLastCol
varDataSelect = "MonthlyReceivedClaims_Data!R1C1:R" & lngLastRowNum & "C" & lngLastCol
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
varDataSelect).CreatePivotTable _
TableDestination:="", TableName:="PivotTable1", DefaultVersion:= _
xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
'Also it helps to use the record macro function under Tools.
'Click record. Make the report or pivot table like you want it. Then click stop record and edit code as needed.
Dim lngLastRow As Long
Dim lngLastCol As Long
Dim varDataSelect As Variant
' Select rows and columns range dynamically.
Selection.End(xlDown).Select
lngLastRowNum = ActiveCell.Row
Selection.End(xlToRight).Select
lngLastCol = ActiveCell.Column
'Name of worksheet "MonthlyReceivedClaims_Data" start at Row 1 Column 1
'and end at ":R" & lngLastRowNum & "C" & lngLastCol
varDataSelect = "MonthlyReceivedClaims_Data!R1C1:R" & lngLastRowNum & "C" & lngLastCol
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
varDataSelect).CreatePivotTable _
TableDestination:="", TableName:="PivotTable1", DefaultVersion:= _
xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
'Also it helps to use the record macro function under Tools.
'Click record. Make the report or pivot table like you want it. Then click stop record and edit code as needed.
Mar 4, 2010 at 10:24 PM