Hi, I've a sheet with an ODBC datapull into it. I also have two manual macros (buttons) on this sheet that I'd like to automate to run everytime the datapull is refreshed (set to 2minutes). I've found the below code and followed it but it's not working...
From: Automatically Run Macro when Cell Changes |
---------------
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.EnableEvents = False
'ENTER YOUR MACRO HERE THAT WILL RUN WHEN CELL CHANGES
Application.EnableEvents = True
End If
End Sub
---------------
The two macros I have that I need to be included are....
---------------
Sub AllWorkbookPivots()Dim pt As PivotTable
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
For Each pt In ws.PivotTables
pt.RefreshTable
Next pt
Next ws
End Sub
---------------
Sub Update_All_Manually_Calculated_Fields()
'
' Update_All_Manually_Calculated_Fields Macro
' Columns R-V
'
'
Range("R2:V2").Select
Selection.AutoFill Destination:=Range("R2:V1947"), Type:=xlFillDefault
Range("R2:V1947").Select
Range("Q1911").Select
Selection.End(xlUp).Select
Range("Q797").Select
End Sub
---------------
My sheet which the code needs to be entered into is 'Sheet4.All Open Tickets'.
From: Automatically Run Macro when Cell Changes |
---------------
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.EnableEvents = False
'ENTER YOUR MACRO HERE THAT WILL RUN WHEN CELL CHANGES
Application.EnableEvents = True
End If
End Sub
---------------
The two macros I have that I need to be included are....
---------------
Sub AllWorkbookPivots()Dim pt As PivotTable
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
For Each pt In ws.PivotTables
pt.RefreshTable
Next pt
Next ws
End Sub
---------------
Sub Update_All_Manually_Calculated_Fields()
'
' Update_All_Manually_Calculated_Fields Macro
' Columns R-V
'
'
Range("R2:V2").Select
Selection.AutoFill Destination:=Range("R2:V1947"), Type:=xlFillDefault
Range("R2:V1947").Select
Range("Q1911").Select
Selection.End(xlUp).Select
Range("Q797").Select
End Sub
---------------
My sheet which the code needs to be entered into is 'Sheet4.All Open Tickets'.