return ws name formula not working after moving ws to new wb

Reddog94

Board Regular
Joined
Dec 20, 2011
Messages
52
I am using the following formula to display the first 7 characters of a worksheet name in a cell.

=LEFT(MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,256),7)

It works perfectly. However, when I copy the worksheet, move it it a new workbook and save the workbook with a name that is identical to the worksheet name, the formula now returns #VALUE.

Anyone know why the formula no longer works after the copy/move/save?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
1. How are you copying the formula, by highlighting in the formula bar ?
2. Does the new wb have a filename longer than 7 characters ?
 
Upvote 0
See if this helps:

=LEFT(REPLACE(CELL("filename",A1),1,FIND("]",CELL("filename",A1)),""),7)

;)
 
Upvote 0
Never mind:

Just tried it and same problem. Still trying to figure it out.
 
Upvote 0
It works perfectly. However, when I copy the worksheet, move it it a new workbook and save the workbook with a name that is identical to the worksheet name, the formula now returns #VALUE.

This is what I found out with a few tests:

1. If you are R/Clicking the Tab > Move or Copy > Create Copy >(new book)
2. Then saving the (new book) as ANY name, you will get the error.

If you create the new book first, name it, then Copy the sheet over, the formula will work.

Don't know why, but that's what happened with my testing. :confused:
 
Upvote 0
Well rats - the copy/move/save is done in with code, which says to copy the ws, move it to a new book, then name the new book with the name of the ws. My vba is too limited to know how to create the new book and name it the ws name before copying the ws over - but I'll keep working on it...

Thanks all.
 
Upvote 0
Why don't you post the code, it might help us, help you solve the problem
 
Upvote 0
Michael - I should have done that to begin with, sorry (I'm new and still learning). However, I fixed this problem by doing a copy/paste value in the cell in question before copying it to the new workbook. I only needed the formula to populate the data upon creation, after that it's fine to hard code it. Thanks for all your help!
 
Upvote 0

Forum statistics

Threads
1,215,708
Messages
6,126,363
Members
449,311
Latest member
accessbob

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