Can someone check my VBA code? Auto pivot table refresh and sheet name change

mnmgal

New Member
Joined
Jan 9, 2025
Messages
1
Office Version
  1. 365
  2. 2024
  3. 2021
  4. 2019
  5. 2016
Platform
  1. Windows
Hi,
Can someone please check my VBA code? I only have 2 components, one to change the sheet name to match cell C114 and the other to automatically refresh the pivot table when the source data changes (theyre both on the same sheet). Thank you

Private Sub Worksheet_Change(ByVal Target As Range)

ActiveSheet.Name = ActiveSheet.Range("C114").Value


Application.EnableEvents = False

ThisWorkbook.RefreshAll

Application.EnableEvents = True

End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi @mnmgal and welcome to MrExcel.

What is the problem with your code?

For it to work automatically, the code must be in the events of the sheet, for that you must do the following: Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.

That way the code will be executed every time you modify any cell in the sheet.
 
Upvote 0

Forum statistics

Threads
1,225,488
Messages
6,185,281
Members
453,285
Latest member
Wullay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top