Macros dont work after changing workbook Filename

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
785
Office Version
  1. 365
Platform
  1. Windows
Hi,
when i set up my workbook i just named it test.xlsm and ive got a lot of formulas and macros in it now.

Ive looked through my VBA code and theres no reference to "test.xlsm" but if i change the filename all my macros fail to work.

Is there a reason for this? and any solution rather then copy/paste all codes 1 by 1.

Thanks in advance
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
but if i change the filename all my macros fail to work.

What does "fail to work" exactly mean? Do you get an error? If yes what's the error description and what line of code is highlighted?

Can you show the code for one of the macro's that fails?
 
Last edited:
Upvote 0
thanks guys but ive managed to fix it

Code:
Sub ClearData()
'
' ClearData Macro
'

'
        Sheets("Sheet1").Select
    Range("A2:H791").Select
    Selection.ClearContents
    Sheets("Pivot").Select
    ActiveSheet.PivotTables("PivotTable6").PivotCache.Refresh
    
    
    Sheets("Main").Select
    
End Sub

because my macro pulls data from a pivot table, i simply had to change the data source for pivot table to new filename
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,557
Latest member
richa mishra

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