Vgabond
Board Regular
- Joined
- Jul 22, 2008
- Messages
- 197
Hi ALL
I'm recorded a macro and manage to use but my challenge is that I have to keep changing the file name in order to make it run ( for different file). Below is the code and the one that highlighted in RED is the file name which I have to change everytime I run a new file. Any help is much appreciated. Thanks
:
I'm recorded a macro and manage to use but my challenge is that I have to keep changing the file name in order to make it run ( for different file). Below is the code and the one that highlighted in RED is the file name which I have to change everytime I run a new file. Any help is much appreciated. Thanks
:
Code:
Sub Submit()
'
' Submit Macro
' Macro recorded 21/03/2011 by Vgabond
'
'
Rows("1:1").Select
Range("AA1").Activate
Selection.Find(What:="submit", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Columns("BC:BC").Select
Selection.TextToColumns Destination:=Range("BC1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
:=Array(Array(1, 4), Array(2, 9), Array(3, 9)), TrailingMinusNumbers:=True
Range("A1:CW3729").Select
Range("AX7").Activate
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"[COLOR=Red][B]Submission_23032011[/B][/COLOR]!R1C1:R3729C101").CreatePivotTable TableDestination:="", TableName _
:="PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Submit")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("TelNum"), "Count of TelNum", xlCount
ActiveWorkbook.Save
End Sub