Excel friends,
The code wks.Range(rngAddress).Activate is not working. It generates a runtime error 91. Can somebody help me. Thanks!
Thanks again!
The code wks.Range(rngAddress).Activate is not working. It generates a runtime error 91. Can somebody help me. Thanks!
Code:
Sub PivotTableMacro()
Dim wks As Worksheet
Dim wb As Workbook
Set wb = ActiveWorkbook
Dim pt As PivotTable
Dim rngAddress As Range
For Each wks In wb.Sheets
For Each pt In wks.PivotTables
rngAddress = Chr(34) & Left(pt.TableRange1.Address, InStr(1, pt.TableRange1.Address, ":") - 1) & Chr(34)
wks.Range(rngAddress).Activate 'I need this code to activate or select the cell rngAddress
Application.Run "SpecialMacro" ' this Special Macro macro will run only if one cell is selected inside the current pt.
MsgBox rngAddress ' for example, it shows "G10"
Next pt
Next wks
End Sub
Thanks again!