weefisheads
Active Member
- Joined
- Mar 18, 2006
- Messages
- 353
I'm trying to write a macro that will take some data, clean it up, and then convert the data into a pivot table. Alas, I can't seem to come up with a way to make it so that the source data for the pivot table is dynamic.
As I'm pretty weak at writing code outright, I usually record what I want to do and work from there. By doing this, I end up with code that look like this -
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"'Data.rdl'!R1C1:R43C6").CreatePivotTable TableDestination:="", _
TableName:="PivotTable1", DefaultVersion:=xlPivotTableVersion10
This is fine and dandy if the data range is A1:F43, but though the data is always 6 colums wide, it can be anywhere between 10 and 10000 rows long.
I've tried using
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
but I can't seem to get around naming an absolute range for the SourceDate:=
Any suggestions? I'm sure it's something quite obvious, but the syntax eludes me.
Thanks,
dB
As I'm pretty weak at writing code outright, I usually record what I want to do and work from there. By doing this, I end up with code that look like this -
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"'Data.rdl'!R1C1:R43C6").CreatePivotTable TableDestination:="", _
TableName:="PivotTable1", DefaultVersion:=xlPivotTableVersion10
This is fine and dandy if the data range is A1:F43, but though the data is always 6 colums wide, it can be anywhere between 10 and 10000 rows long.
I've tried using
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
but I can't seem to get around naming an absolute range for the SourceDate:=
Any suggestions? I'm sure it's something quite obvious, but the syntax eludes me.
Thanks,
dB