ISREF syntaxx

dhancy

Board Regular
Joined
Jul 10, 2013
Messages
120
Office Version
  1. 2016
Platform
  1. Windows
In Excel VBA, I can run this code:

Code:
if evaluate("ISREF('Sheet1'!A1)") then

I now want to expand on that to refer to a sheet on another open workbook.

I found this syntax online:

Code:
if evaluate("ISREF('[MyFile.xlsm]Sheet1'!A1)") then

If Sheet1 exists, it returns true.

If Sheet1 does not exist, I get "Error 2015".

Shouldn't it return False in that case? Perhaps there is different syntax I should use? Can you help? Thanks!


Dennis
 
Re: Help with ISREF syntaxx

You can use it like
Code:
   If Evaluate("isref(pcode!a1)") Then MsgBox "ok"
For the activeworkbook
 
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Re: Help with ISREF syntaxx

Or like this for an inactive workbook
Rich (BB code):
   If Evaluate("isref('[rwc 2019.xlsx]info'!a1)") Then MsgBox "ok"
 
Upvote 0
Re: Help with ISREF syntaxx

Or like this for an inactive workbook
Rich (BB code):
   If Evaluate("isref('[rwc 2019.xlsx]info'!a1)") Then MsgBox "ok"
Why is this bad if all I am trying to do is find out if a certain worksheet is there or not there on that workbook? I can add this code if it is there and if it s not there I can do an else statement to add the sheet to the front and then add a table of contents. I am just trying to figure something out like I did this and got no error messages whether it was there or not.
 
Upvote 0
Re: Help with ISREF syntaxx

I'm afraid I don't understand what you are saying.
 
Upvote 0
Re: Help with ISREF syntaxx

I'm afraid I don't understand what you are saying.
I don't remember what post it was on stackoverflow.com it was but someone said that it was not a good idea to use that way to see if a sheet was available. However, I am trying to figure out why? I ran the sub procedure three different times. 1. to see if it was actually a worksheet, if it wasn't a worksheet and again if the worksheet already existed, still no issues using that version of the isref formula on the spreadsheet. Do you see or for see any reason that would not be the proper way to search for a worksheet.
 
Upvote 0
Re: Help with ISREF syntaxx

When checking if a sheet exists in the active workbook I use Isref, otherwise I use a function similar to post#9
 
Upvote 0
Re: Help with ISREF syntaxx

When checking if a sheet exists in the active workbook I use Isref, otherwise I use a function similar to post#9

Thank you very much I will use this information when creating my TOC and other personal macros.
 
Upvote 0
Re: Help with ISREF syntaxx

You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,810
Messages
6,121,690
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