VBA rename sheet based on a string in a cell reference

jrg24

New Member
Joined
Aug 6, 2010
Messages
49
I have code that pulls one particular sheet from all workbooks in a directory. Once all the sheets are in, I have them renaming based on the value of a cell. Unfortunately, my preferred name for the sheet does not exist anywhere on the sheet except as a string inside a cell reference. (for example, Cell C6 in my worksheet contains the formula "=+'A:\New Quarterly Process\Q2 2018\Sent Templates\[BR-RIO-2Q2018 Reforecast Template.xlsm]Overheads'!N74". I want to rename my sheet BR-RIO. How would I go about doing that?

thanks for any help you might be able to provide.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
You could use something like this to extract the required string from the formula.
Code:
    strShName = Mid(Range("C6").Formula, InStr(Range("C6").Formula, "[") + 1)

    strShName = Split(strShName, "-")(0) & "-" & Split(strShName, "-")(1)
 
Upvote 0
You could use something like this to extract the required string from the formula.
Code:
    strShName = Mid(Range("C6").Formula, InStr(Range("C6").Formula, "[") + 1)

    strShName = Split(strShName, "-")(0) & "-" & Split(strShName, "-")(1)


Thanks, Norie. This does exactly what I needed to do.
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,876
Members
452,949
Latest member
Dupuhini

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