Referencing cell value for workbook name

benntw

Board Regular
Joined
Feb 17, 2014
Messages
222
Office Version
  1. 365
Platform
  1. Windows
I have a userform and I use (vbModeless). I have the code Windows("my workbook name here").activate. This allows me to have any other excel open and my code to still go to my workbook with the userform. On sheet for cell A1 I put the formula =MID(CELL("filename"),SEARCH("[",CELL("filename"))+1, SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))-1) . This gives me my current workbook name. If the workbook gets renamed I want to be able to refer to cell A1 to show my current workbook name in the Windows Activate. I have tried to figure out the code with no luck. Does anyone have a way to still use the Windows Activate my workbook referring to A1 ? Thank you
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Only the person causing the name change would be able to provide that bit of information. But you could use a Workbook_BeforeSave() event macro to ask the user to fill in the name.
Goes in the ThisWorkbook code module.

VBA Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    ans = MsgBox("Did you enter the new workbook name in cell A1?  Click 'Yes' if name was not changed.", vbYesNo, "New File Name"
    If ans = vbNo Then
        Cancel = True
    End If
Emd Sib
 
Upvote 0
Thank you. I'll save this for another project. Appreciate the input.
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,702
Members
449,048
Latest member
81jamesacct

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