Mr_Ragweed
Board Regular
- Joined
- Dec 10, 2012
- Messages
- 74
Hello, I'm new to loops. I need to write a macro that creates a PT for each column in a datasheet. The number of columns and rows is variable. The PT is simple it will only use Column A and then 1 other column at a time. I would show you my code but i'm having trouble with where to even start. I'm struggling with the Ranges (assuming dynamic ranges?) as much as I am writing a loop. Possible declarations are as follows:
' DCol stands for DataColumn
Dim DCol as Column
Dim WSD as Worksheets("name")
Dim FinalRow as Long
Dim FinalCol as Long
Dim PT as PivotTable
Dim ("A") as Range
Dim ? as Range
FinalRow = WSD.Cells(Application.Rows.Count, 1).End(xlUp)
FinalCol = WSD.Cells(1, Application.Columns.Count).End(xlToLeft).Column
So from here i have to type in english what i want:
For each DCol & "A", create a PT.
I can handle the location and formatting of the tables (or i've at least convinced myself that I can).
When we solve this I will probably be back with Userform questions as i want to make a userform that lets the user control the groupings of each resultant PT. If it helps the data sheet is actually from a much larger PT. If its easier to extract what i need from there, i'm all ears. Users will never see anything but the tables i'm trying to create.
Thanks in advance, Mr_Ragweed.
' DCol stands for DataColumn
Dim DCol as Column
Dim WSD as Worksheets("name")
Dim FinalRow as Long
Dim FinalCol as Long
Dim PT as PivotTable
Dim ("A") as Range
Dim ? as Range
FinalRow = WSD.Cells(Application.Rows.Count, 1).End(xlUp)
FinalCol = WSD.Cells(1, Application.Columns.Count).End(xlToLeft).Column
So from here i have to type in english what i want:
For each DCol & "A", create a PT.
I can handle the location and formatting of the tables (or i've at least convinced myself that I can).
When we solve this I will probably be back with Userform questions as i want to make a userform that lets the user control the groupings of each resultant PT. If it helps the data sheet is actually from a much larger PT. If its easier to extract what i need from there, i'm all ears. Users will never see anything but the tables i'm trying to create.
Thanks in advance, Mr_Ragweed.