From a previous thread ... I requested where to start to learn VBA and resoundingly the concensus is to create macros and read them... learn what the code is doing...
In that vein, I have pressed on. Here are my first findings.
========================================
I created 2 macros... the first one works, the second one doesnt but I know why it doesn't, its variables and I don't know if taming the variables is possible. If it is then just let me know. Its not important at this time that I tame the variable because I'm just trying to test the boundaries of a macro.
The first macro takes information I have copied from a report on the web and it Inserts a column between A and B so that I can use Text To Columns and separate the data at the comma.
02/15/2010,21:49:00
I need the dates only so I just split off the time. That works. I stopped recording because this next section did not work so I thought well record it separate and see what happens. I get it.
Its breaking at the sheet reference because when it creates a new worksheet, the sheet number will change. So I deleted the one that I had,knowing the next numbered sheet would be Sheet10 and I entered that into the macro in the two sheet reference locations.
It created a pivot table but when I recorded the macro it did not catch one function.
The Date Column (Column A) when I create a pivot table manually is drug into the ROW LABELS box and it is also drug into the VALUES box because I am checking to see how many pending files we have and from what dates.
The macro did not drag the date into the ROW LABELS box, only into the VALUES box.
So the 2 things I'm wondering about are these:
1. How does one deal with the changing sheet number differences to use this daily. I do this EVERY DAY in a new workbook EVERY DAY.
2. Why didn't the ROW LABELS thing work but the VALUES does?
I am going to try this again but this time keep the pivot on the same page as the data and see if it works.
I tried the same creating the pivot table in column J on the sheet where the data resides but again the ROW Labels did not take, I was able to add them after the macro stopped however.
I'm never going to know what the sheet number may or may not be depending on how many interruptions I get during the day.
The first macro and a matching one to insert columns and split the text work FANTASTICALLY but the next question is this. How do I move this to the new workbook I create tomorrow?
How does one copy a macro from worksheet to worksheet?
(By the way... be careful what you suggest, you may very well be creating a MONSTER) hehehe
Thanks.... in advance
LadyCK3
aka: Laurie
In that vein, I have pressed on. Here are my first findings.
========================================
I created 2 macros... the first one works, the second one doesnt but I know why it doesn't, its variables and I don't know if taming the variables is possible. If it is then just let me know. Its not important at this time that I tame the variable because I'm just trying to test the boundaries of a macro.
The first macro takes information I have copied from a report on the web and it Inserts a column between A and B so that I can use Text To Columns and separate the data at the comma.
02/15/2010,21:49:00
I need the dates only so I just split off the time. That works. I stopped recording because this next section did not work so I thought well record it separate and see what happens. I get it.
Code:
Sub PendPiv()
'
' PendPiv Macro
' ceate Pivot Table for Pending
'
' Keyboard Shortcut: Ctrl+t
'
Columns("A:H").Select
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R1C1:R1048576C8", Version:=xlPivotTableVersion12).CreatePivotTable _
TableDestination:="Sheet10!R3C1", TableName:="PivotTable2", DefaultVersion _
:=xlPivotTableVersion12
Sheets("Sheet10").Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable2").PivotFields("Date")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
"PivotTable2").PivotFields("Date"), "Count of Date", xlCount
End Sub
Its breaking at the sheet reference because when it creates a new worksheet, the sheet number will change. So I deleted the one that I had,knowing the next numbered sheet would be Sheet10 and I entered that into the macro in the two sheet reference locations.
It created a pivot table but when I recorded the macro it did not catch one function.
The Date Column (Column A) when I create a pivot table manually is drug into the ROW LABELS box and it is also drug into the VALUES box because I am checking to see how many pending files we have and from what dates.
The macro did not drag the date into the ROW LABELS box, only into the VALUES box.
So the 2 things I'm wondering about are these:
1. How does one deal with the changing sheet number differences to use this daily. I do this EVERY DAY in a new workbook EVERY DAY.
2. Why didn't the ROW LABELS thing work but the VALUES does?
I am going to try this again but this time keep the pivot on the same page as the data and see if it works.
I tried the same creating the pivot table in column J on the sheet where the data resides but again the ROW Labels did not take, I was able to add them after the macro stopped however.
I'm never going to know what the sheet number may or may not be depending on how many interruptions I get during the day.
The first macro and a matching one to insert columns and split the text work FANTASTICALLY but the next question is this. How do I move this to the new workbook I create tomorrow?
How does one copy a macro from worksheet to worksheet?
(By the way... be careful what you suggest, you may very well be creating a MONSTER) hehehe
Thanks.... in advance
LadyCK3
aka: Laurie