For the following script, I have one issue where I need to ask the user for the month in cell N16 as there is no logical way to figure out the correct tab without user input.
So for the line in Macro 3 listed as Worksheets("July 2018").Activate, I need assistance on pulling the Worksheet name in cell N16 of "Start" tab that the user would input.
Any help on calling this Worksheet name would be greatly appreciated.
Thank you,
Ray
===================================================
So for the line in Macro 3 listed as Worksheets("July 2018").Activate, I need assistance on pulling the Worksheet name in cell N16 of "Start" tab that the user would input.
Any help on calling this Worksheet name would be greatly appreciated.
Thank you,
Ray
===================================================
Code:
Option Private Module
Sub Macro1()
Dim ws As Worksheet
Set ws = Sheets("Start")
MsgBox ("Update may take several minutes, Click Ok to begin")
Workbooks.Open ws.Range("N10").Value
'Selection.AutoFilter
Range("A1:P224").Select
Selection.Copy
Windows("VBA Extractor r57with code V2.xlsm").Activate
Worksheets("Invoice Summary").Activate
ActiveCell.Offset(0, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False
Call Macro2(ws)
End Sub
Sub Macro2(ws As Worksheet)
' Macro2 Macro
'
' Keyboard Shortcut: Ctrl+f
'
Workbooks.Open ws.Range("N12").Value
'Selection.AutoFilter
ActiveCell.Offset(0, 0).Range("A1:AQ35000").Select
Selection.Copy
Windows("VBA Extractor r57with code V2.xlsm").Activate
Worksheets("Vendor Master").Activate
ActiveCell.Offset(-1, 0).Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False
Call Macro3(ws)
End Sub
Sub Macro3(ws As Worksheet)
'
' Macro3 Macro
'
' Keyboard Shortcut: Ctrl+g
'
Workbooks.Open ws.Range("N14").Value
[U][B] Worksheets("July 2018").Activate[/B][/U]
Range("A3").Select
Selection.AutoFilter
Columns("A:E").Select
Selection.EntireColumn.Hidden = False
Rows("3:3").Select
Selection.AutoFilter
ActiveCell.Offset(0, 0).Range("A2:BR26000").Select
ActiveSheet.Range("$E2").AutoFilter Field:=5, Criteria1:= _
"Vendor"
Selection.Copy
Windows("VBA Extractor r57with code V2.xlsm").Activate
Worksheets("Const. Prog. Rpt Switches").Activate
ActiveCell.Offset(0, 0).Range("A1").Select
'ActiveCell.Offset(0, 0).Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False
Call refresh
End Sub
' Refresh all applicable pivot tables to setup month's data
Sub refresh()
'
' refresh Macro
' refresh data
'
' Keyboard Shortcut: Ctrl+r
' replace with Refresh All (had to remove the check for Enable Background refresh to make it wait)
ActiveWorkbook.RefreshAll
' Refresh all Pivot tables in all worksheets
Dim shtTemp As Worksheet
Dim pvtTable As PivotTable
For Each shtTemp In ActiveWorkbook.Worksheets
For Each pvtTable In shtTemp.PivotTables
pvtTable.RefreshTable
Next
Next
MsgBox ("Update Complete,All data is Up-to date")
End Sub
Last edited by a moderator: