VBA code to change sheet reference in formula

nina212001

New Member
Joined
May 19, 2015
Messages
8
I'm not the most proficient with VBA but have been doing a lot of googling to create one. What I've created is VBA code to insert and prompt a title for the new worksheet. I have formulas on a specific worksheet linked to various other worksheets and I need my new row (copy/inserted by the macro already) to change the sheet reference to the new worksheet. Each time the worksheet name will vary because the macro is taking the last row of data and copying/inserting new row after. Formula reference below:
=IF((VLOOKUP(C$3,'Club 6.24.20'!$A:$B,2,FALSE))="","",(VLOOKUP(C$3,'Club 6.24.20'!$A:$B,2,FALSE)))

How do I set the VBA to recognize the old worksheet name and insert the new worksheet name?
 
I included a screenshot so hopefully to help. If I run the previous code, it will take row 12 and insert a copied row below. Meaning row 13 will become the last row for the step to replace sheet reference in formulas. I am using colums A to AO but might have a need to insert additional columns, which was why I hoped to user the entire row as the range. There will not be data below.
Untitled.png
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,224,590
Messages
6,179,756
Members
452,940
Latest member
rootytrip

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