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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
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,223,642
Messages
6,173,510
Members
452,518
Latest member
SoerenB

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