S Oberlander
Board Regular
- Joined
- Nov 25, 2020
- Messages
- 153
- Office Version
- 365
- Platform
- Windows
I have the below code to work on a pivot table, the code works fine the first time I use it in a workbook.
When I use it a second time the
When I use it a second time the
OnAction
is not getting assigned properly and I get this popup when I try to use the command button.
VBA Code:
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
'On Error GoTo ex
Selection.ShowDetail = True
Range("K:K,M:N,E:E,O:Y").EntireColumn.Hidden = True
ct = Range("F2")
If Evaluate("isref('" & ct & "'!A1)") Then
Application.DisplayAlerts = False
Sheets(ct).Delete
Application.DisplayAlerts = True
End If
ActiveSheet.Name = ct
ActiveSheet.Buttons.Add(937.5, 23.25, 114.75, 27).Select
Selection.OnAction = "R:\Macro Data\RP Macro Wrkbk!refreshT"
Selection.Characters.Text = "Refresh Table"
Range("A1").Select
ex:
End Sub