Detect if Reference Workbook is Open

Roderick_E

Well-known Member
Joined
Oct 13, 2007
Messages
2,051
I've seen VBA solutions to detect if a reference workbook is open, but is there a formulaic solution without using a UDF?
Thanks
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
You might be able to use something like this:

If a workbook is linked...AND...is currently open
the linking formula has this structure:
Code:
D2: ='[FileName.xlsx]Sheet1'!A1

BUT...if the file is NOT open
the linking formula has this structure:
Code:
D2: ='C:\FolderName\[FileName.xlsx]Sheet1'!A1

So, you might be able to use the FORMULATEXT function to return the formula in the cell and maybe search for a specific pattern:

Code:
E2: =IF(ISERR(SEARCH(":\",FORMULATEXT(D2))),"Open","Closed")
Note: The search term is COLON BACKSLASH....The website may corrupt that.

Is that something you can work with?
 
Upvote 0
You might be able to use something like this:

If a workbook is linked...AND...is currently open
the linking formula has this structure:
Code:
D2: ='[FileName.xlsx]Sheet1'!A1

BUT...if the file is NOT open
the linking formula has this structure:
Code:
D2: ='C:\FolderName\[FileName.xlsx]Sheet1'!A1

So, you might be able to use the FORMULATEXT function to return the formula in the cell and maybe search for a specific pattern:

Code:
E2: =IF(ISERR(SEARCH(":\",FORMULATEXT(D2))),"Open","Closed")
Note: The search term is COLON BACKSLASH....The website may corrupt that.

Is that something you can work with?

Going to test this and will report back thanks
 
Upvote 0
You might be able to use something like this:

If a workbook is linked...AND...is currently open
the linking formula has this structure:
Code:
D2: ='[FileName.xlsx]Sheet1'!A1

BUT...if the file is NOT open
the linking formula has this structure:
Code:
D2: ='C:\FolderName\[FileName.xlsx]Sheet1'!A1

So, you might be able to use the FORMULATEXT function to return the formula in the cell and maybe search for a specific pattern:

Code:
E2: =IF(ISERR(SEARCH(":\",FORMULATEXT(D2))),"Open","Closed")
Note: The search term is COLON BACKSLASH....The website may corrupt that.

Is that something you can work with?

Ok I can work with this thanks. Testing shows that I can't simply put the link into the Formulatext part, I have to reference another cell, but it will still work.
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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