+ Reply to Thread
Results 1 to 4 of 4

reference current worksheet name (tab name) in a formula

  1. #1
    Janet Panighetti
    Guest

    reference current worksheet name (tab name) in a formula

    How may I reference the current worksheet name (the name on the tab) in a
    formula on that worksheet.

    In other words, I want to compare the string in a cell to the name of the
    current worksheet. If it matches then I want to raise an error.

    Thanks in advance!

    Janet


  2. #2
    Trevor Shuttleworth
    Guest

    Re: reference current worksheet name (tab name) in a formula

    Janet

    courtesy of:

    www.ozgrid.com http://www.ozgrid.com/VBA/return-sheet-name.htm
    Return an Excel Worksheet Name to a Cell

    In Excel it is possible to use the CELL function/formula and the MID and
    FIND to return the name of an Excel Worksheet in a Workbook. The formula
    below shows us how;

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

    Where A1 is any non error cell on the Worksheet. If you want the full path
    of the Excel Workbook, simply use;

    =CELL("filename",A1)

    It is important to note that the above formulas will only work in a Workbook
    that has been saved.

    Search Google for: cell worksheet name excel for other references

    Regards

    Trevor


    "Janet Panighetti" <JanetPanighetti@discussions.microsoft.com> wrote in
    message news:E475F554-4CF1-4391-B06B-C22EF86528B9@microsoft.com...
    > How may I reference the current worksheet name (the name on the tab) in a
    > formula on that worksheet.
    >
    > In other words, I want to compare the string in a cell to the name of the
    > current worksheet. If it matches then I want to raise an error.
    >
    > Thanks in advance!
    >
    > Janet
    >




  3. #3
    Janet Panighetti
    Guest

    Re: reference current worksheet name (tab name) in a formula

    Very cool, Trevor!

    Since all the worksheet names are a 6 digit number, I modified your
    suggestion to the following:

    =RIGHT(CELL("FILENAME",A1),6)

    and it works GREAT!!!!!!!!!!!!!! I'll just have to remember to save the
    workbook to get the new tabnames.

    Thanks!!!!!!!!!!

    Janet


    "Trevor Shuttleworth" wrote:

    > Janet
    >
    > courtesy of:
    >
    > www.ozgrid.com http://www.ozgrid.com/VBA/return-sheet-name.htm
    > Return an Excel Worksheet Name to a Cell
    >
    > In Excel it is possible to use the CELL function/formula and the MID and
    > FIND to return the name of an Excel Worksheet in a Workbook. The formula
    > below shows us how;
    >
    > =MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,256)
    >
    > Where A1 is any non error cell on the Worksheet. If you want the full path
    > of the Excel Workbook, simply use;
    >
    > =CELL("filename",A1)
    >
    > It is important to note that the above formulas will only work in a Workbook
    > that has been saved.
    >
    > Search Google for: cell worksheet name excel for other references
    >
    > Regards
    >
    > Trevor
    >
    >
    > "Janet Panighetti" <JanetPanighetti@discussions.microsoft.com> wrote in
    > message news:E475F554-4CF1-4391-B06B-C22EF86528B9@microsoft.com...
    > > How may I reference the current worksheet name (the name on the tab) in a
    > > formula on that worksheet.
    > >
    > > In other words, I want to compare the string in a cell to the name of the
    > > current worksheet. If it matches then I want to raise an error.
    > >
    > > Thanks in advance!
    > >
    > > Janet
    > >

    >
    >
    >


  4. #4
    Trevor Shuttleworth
    Guest

    Re: reference current worksheet name (tab name) in a formula

    Janet

    you're very welcome. Thanks for the feedback. As I said, credit to OZGRID
    for this solution, although you'll find it in lots of other places.

    Regards

    Trevor


    "Janet Panighetti" <JanetPanighetti@discussions.microsoft.com> wrote in
    message news:B014ECD7-6F6B-4395-8CD7-00314C147E59@microsoft.com...
    > Very cool, Trevor!
    >
    > Since all the worksheet names are a 6 digit number, I modified your
    > suggestion to the following:
    >
    > =RIGHT(CELL("FILENAME",A1),6)
    >
    > and it works GREAT!!!!!!!!!!!!!! I'll just have to remember to save the
    > workbook to get the new tabnames.
    >
    > Thanks!!!!!!!!!!
    >
    > Janet
    >
    >
    > "Trevor Shuttleworth" wrote:
    >
    >> Janet
    >>
    >> courtesy of:
    >>
    >> www.ozgrid.com http://www.ozgrid.com/VBA/return-sheet-name.htm
    >> Return an Excel Worksheet Name to a Cell
    >>
    >> In Excel it is possible to use the CELL function/formula and the MID and
    >> FIND to return the name of an Excel Worksheet in a Workbook. The formula
    >> below shows us how;
    >>
    >> =MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,256)
    >>
    >> Where A1 is any non error cell on the Worksheet. If you want the full
    >> path
    >> of the Excel Workbook, simply use;
    >>
    >> =CELL("filename",A1)
    >>
    >> It is important to note that the above formulas will only work in a
    >> Workbook
    >> that has been saved.
    >>
    >> Search Google for: cell worksheet name excel for other references
    >>
    >> Regards
    >>
    >> Trevor
    >>
    >>
    >> "Janet Panighetti" <JanetPanighetti@discussions.microsoft.com> wrote in
    >> message news:E475F554-4CF1-4391-B06B-C22EF86528B9@microsoft.com...
    >> > How may I reference the current worksheet name (the name on the tab) in
    >> > a
    >> > formula on that worksheet.
    >> >
    >> > In other words, I want to compare the string in a cell to the name of
    >> > the
    >> > current worksheet. If it matches then I want to raise an error.
    >> >
    >> > Thanks in advance!
    >> >
    >> > Janet
    >> >

    >>
    >>
    >>




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1