Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
locutus243
 
Posts: n/a
Default Tracking worksheet names in functions


Hey guys, bit of a puzzler for you:-

I am trying to create a formula that is based on worksheet names, such
as 'If a worksheet called 'Tuesday' exists then type 1. Is there anyway
that worksheet names can be used in this way??

Thanks

Mark


--
locutus243
------------------------------------------------------------------------
locutus243's Profile: http://www.excelforum.com/member.php...o&userid=12862
View this thread: http://www.excelforum.com/showthread...hreadid=490724

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JE McGimpsey
 
Posts: n/a
Default Tracking worksheet names in functions

One way, using a User Defined Function:

Public Function SheetExists(sName As String) As Boolean
Dim sTemp As String
Application.Volatile
On Error Resume Next
sTemp = Sheets(sName).Name
SheetExists = Err = 0
On Error GoTo 0
End Function

Call as

=IF(SheetExists("Tuesday"),1,"something else")

or perhaps

=--SheetExists("Tuesday")


In article ,
locutus243
wrote:

Hey guys, bit of a puzzler for you:-

I am trying to create a formula that is based on worksheet names, such
as 'If a worksheet called 'Tuesday' exists then type 1. Is there anyway
that worksheet names can be used in this way??

Thanks

Mark

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bernie Deitrick
 
Posts: n/a
Default Tracking worksheet names in functions

Mark,

You would need to use VBA to create a custom function: copy the function below into a regular code
module, and use it like so:

=IF(ShtExists("Tuesday"),1,0)
or
=IF(ShtExists("Tuesday"),"Tuesday exists","Tuesday doesn't exist")

HTH,
Bernie
MS Excel MVP


Function ShtExists(myName As String) As Boolean
Dim mySht As Worksheet
ShtExists = False
For Each mySht In Application.Caller.Parent.Parent.Worksheets
If mySht.Name = myName Then
ShtExists = True
Exit Function
End If
Next mySht
End Function


"locutus243" wrote in message
...

Hey guys, bit of a puzzler for you:-

I am trying to create a formula that is based on worksheet names, such
as 'If a worksheet called 'Tuesday' exists then type 1. Is there anyway
that worksheet names can be used in this way??

Thanks

Mark


--
locutus243
------------------------------------------------------------------------
locutus243's Profile: http://www.excelforum.com/member.php...o&userid=12862
View this thread: http://www.excelforum.com/showthread...hreadid=490724



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default Tracking worksheet names in functions

=IF(ISERROR(CELL("address",INDIRECT("'tuesday'!a1" ))),0,1)

or if Tuesday were in A1:

=IF(ISERROR(CELL("address",INDIRECT("'"&A1&"'!a1") )),0,1)




locutus243 wrote:

Hey guys, bit of a puzzler for you:-

I am trying to create a formula that is based on worksheet names, such
as 'If a worksheet called 'Tuesday' exists then type 1. Is there anyway
that worksheet names can be used in this way??

Thanks

Mark

--
locutus243
------------------------------------------------------------------------
locutus243's Profile: http://www.excelforum.com/member.php...o&userid=12862
View this thread: http://www.excelforum.com/showthread...hreadid=490724


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bernie Deitrick
 
Posts: n/a
Default Tracking worksheet names in functions

Dave,

Much better solution. But why not just?

=IF(ISERROR(INDIRECT("'Tuesday'!a1")),0,1)

HTH,
Bernie
MS Excel MVP


"Dave Peterson" wrote in message
...
=IF(ISERROR(CELL("address",INDIRECT("'tuesday'!a1" ))),0,1)

or if Tuesday were in A1:

=IF(ISERROR(CELL("address",INDIRECT("'"&A1&"'!a1") )),0,1)




locutus243 wrote:

Hey guys, bit of a puzzler for you:-

I am trying to create a formula that is based on worksheet names, such
as 'If a worksheet called 'Tuesday' exists then type 1. Is there anyway
that worksheet names can be used in this way??

Thanks

Mark

--
locutus243
------------------------------------------------------------------------
locutus243's Profile: http://www.excelforum.com/member.php...o&userid=12862
View this thread: http://www.excelforum.com/showthread...hreadid=490724


--

Dave Peterson





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default Tracking worksheet names in functions

What happens if Tuesday!A1 contains an error?


Bernie Deitrick wrote:

Dave,

Much better solution. But why not just?

=IF(ISERROR(INDIRECT("'Tuesday'!a1")),0,1)

HTH,
Bernie
MS Excel MVP

"Dave Peterson" wrote in message
...
=IF(ISERROR(CELL("address",INDIRECT("'tuesday'!a1" ))),0,1)

or if Tuesday were in A1:

=IF(ISERROR(CELL("address",INDIRECT("'"&A1&"'!a1") )),0,1)




locutus243 wrote:

Hey guys, bit of a puzzler for you:-

I am trying to create a formula that is based on worksheet names, such
as 'If a worksheet called 'Tuesday' exists then type 1. Is there anyway
that worksheet names can be used in this way??

Thanks

Mark

--
locutus243
------------------------------------------------------------------------
locutus243's Profile: http://www.excelforum.com/member.php...o&userid=12862
View this thread: http://www.excelforum.com/showthread...hreadid=490724


--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JE McGimpsey
 
Posts: n/a
Default Tracking worksheet names in functions

Very nice. I like this version a bit better, but it's personal taste:

=1-ISERROR(CELL("address",INDIRECT("'tuesday'!a1")))

In article ,
Dave Peterson wrote:

=IF(ISERROR(CELL("address",INDIRECT("'tuesday'!a1" ))),0,1)

or if Tuesday were in A1:

=IF(ISERROR(CELL("address",INDIRECT("'"&A1&"'!a1") )),0,1)




locutus243 wrote:

Hey guys, bit of a puzzler for you:-

I am trying to create a formula that is based on worksheet names, such
as 'If a worksheet called 'Tuesday' exists then type 1. Is there anyway
that worksheet names can be used in this way??

Thanks

Mark

--
locutus243
------------------------------------------------------------------------
locutus243's Profile:
http://www.excelforum.com/member.php...o&userid=12862
View this thread: http://www.excelforum.com/showthread...hreadid=490724

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bernie Deitrick
 
Posts: n/a
Default Tracking worksheet names in functions

Ahh! Since my spreadsheets never contain errors, it's only natural that I forgot about that
possibility... ;-)

Bernie


"Dave Peterson" wrote in message
...
What happens if Tuesday!A1 contains an error?


Bernie Deitrick wrote:

Dave,

Much better solution. But why not just?

=IF(ISERROR(INDIRECT("'Tuesday'!a1")),0,1)

HTH,
Bernie
MS Excel MVP



  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default Tracking worksheet names in functions

I liked it when I stole it from Harlan Grove.



JE McGimpsey wrote:

Very nice. I like this version a bit better, but it's personal taste:

=1-ISERROR(CELL("address",INDIRECT("'tuesday'!a1")))

In article ,
Dave Peterson wrote:

=IF(ISERROR(CELL("address",INDIRECT("'tuesday'!a1" ))),0,1)

or if Tuesday were in A1:

=IF(ISERROR(CELL("address",INDIRECT("'"&A1&"'!a1") )),0,1)




locutus243 wrote:

Hey guys, bit of a puzzler for you:-

I am trying to create a formula that is based on worksheet names, such
as 'If a worksheet called 'Tuesday' exists then type 1. Is there anyway
that worksheet names can be used in this way??

Thanks

Mark

--
locutus243
------------------------------------------------------------------------
locutus243's Profile:
http://www.excelforum.com/member.php...o&userid=12862
View this thread: http://www.excelforum.com/showthread...hreadid=490724


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
listing all names in a worksheet tthe Excel Discussion (Misc queries) 4 January 20th 06 02:19 PM
Worksheet Names (Revised) aftamath Excel Discussion (Misc queries) 2 November 16th 05 02:50 AM
How to get the complete list Excel Worksheet Functions phil Excel Worksheet Functions 1 September 5th 05 01:36 PM
Referencing worksheet names Rich Hayes Excel Worksheet Functions 3 August 25th 05 08:47 PM
create a list of worksheet names (from a single folder, or open files) Drew Excel Discussion (Misc queries) 2 April 15th 05 04:58 PM


All times are GMT +1. The time now is 01:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"