+ Reply to Thread
Results 1 to 7 of 7

SheetName Function

  1. #1
    EXCEL$B!!(BNEWS
    Guest

    SheetName Function

    here is my function

    Function SheetName(x) As String '
    Application.Volatile
    SheetName = ActiveSheet.name
    End Function '

    what i want to do is to get the sheet name in in which a cell (like
    =SheetName(0)) is in.

    not the. name of ActiveSheet.

    what should i do.






  2. #2
    Haldun Alay
    Guest

    Re: SheetName Function

    Function SheetName(x) As String
    Application.Volatile True
    If x <= 0 Then
    SheetName = "Worksheet number must be greater than 0"
    Exit Function
    End If
    With Application.Caller.Parent.Parent
    If x > .Worksheets.Count Then
    SheetName = "Warning: There is no worksheet"
    Else
    SheetName = .Worksheets(x).Name
    End If
    End With
    End Function


    --
    Haldun Alay
    "EXCEL$B!!(BNEWS" <[email protected]>, haber iletisinde ?unlar? yazd?:[email protected]...
    here is my function

    Function SheetName(x) As String '
    Application.Volatile
    SheetName = ActiveSheet.name
    End Function '

    what i want to do is to get the sheet name in in which a cell (like
    =SheetName(0)) is in.

    not the. name of ActiveSheet.

    what should i do.






  3. #3
    Andrew B
    Guest

    Re: SheetName Function

    Hi
    Not sure what you want - do you want to find the cell that contains the
    sheet name ?


    [C3] = activesheet.name will put the sheet name into any cell you
    specify, lik C3. More info needed....

    Andrew B




    EXCEL$B!!(BNEWS wrote:
    > here is my function
    >
    > Function SheetName(x) As String '
    > Application.Volatile
    > SheetName = ActiveSheet.name
    > End Function '
    >
    > what i want to do is to get the sheet name in in which a cell (like
    > =SheetName(0)) is in.
    >
    > not the. name of ActiveSheet.
    >
    > what should i do.
    >
    >
    >
    >
    >


  4. #4
    Edwin Tam
    Guest

    RE: SheetName Function

    I'm not sure what the variable "x" is for in your example.
    But try this:

    Function SHEETNAME() As String
    Dim s As Object
    Application.Volatile
    Set s = Application.Caller
    SHEETNAME = s.Parent.Name
    End Function

    You type in a cell:
    =SHEETNAME()

    The formula will return the sheetname of the sheet where you typed the
    formula.

    Regards,
    Edwin Tam
    [email protected]
    http://www.vonixx.com


    "EXCEL NEWS" wrote:

    > here is my function
    >
    > Function SheetName(x) As String '
    > Application.Volatile
    > SheetName = ActiveSheet.name
    > End Function '
    >
    > what i want to do is to get the sheet name in in which a cell (like
    > =SheetName(0)) is in.
    >
    > not the. name of ActiveSheet.
    >
    > what should i do.
    >
    >
    >
    >
    >
    >


  5. #5
    Ardus Petus
    Guest

    Re: SheetName Function

    Maybe someting like this:

    "------------------------------
    Function sheetname(rng As Range) As String
    sheetname = rng.Worksheet.Name
    End Function
    '------------------------------

    HTH
    --
    AP

    "EXCEL$B!!(BNEWS" <[email protected]> a ecrit dans le message de
    news:[email protected]...
    > here is my function
    >
    > Function SheetName(x) As String '
    > Application.Volatile
    > SheetName = ActiveSheet.name
    > End Function '
    >
    > what i want to do is to get the sheet name in in which a cell (like
    > =SheetName(0)) is in.
    >
    > not the. name of ActiveSheet.
    >
    > what should i do.
    >
    >
    >
    >
    >




  6. #6
    Randy Harmelink
    Guest

    Re: SheetName Function

    Try this formula:

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

    However, it will only work in sheets that have been saved, because
    "filename" is an attribute that is set when the file is saved.

    That came from:

    http://www.ozgrid.com/VBA/return-sheet-name.htm


  7. #7
    EXCEL NEWS
    Guest

    Re: SheetName Function

    thanks to all of you.
    i have thought it out ,like Mr Edwin Tam suggested to me,
    i will do better with his advice
    thanks


    "Edwin Tam" <[email protected]> wrote in message
    news:[email protected]...
    > I'm not sure what the variable "x" is for in your example.
    > But try this:
    >
    > Function SHEETNAME() As String
    > Dim s As Object
    > Application.Volatile
    > Set s = Application.Caller
    > SHEETNAME = s.Parent.Name
    > End Function
    >
    > You type in a cell:
    > =SHEETNAME()
    >
    > The formula will return the sheetname of the sheet where you typed the
    > formula.
    >
    > Regards,
    > Edwin Tam
    > [email protected]
    > http://www.vonixx.com
    >
    >
    > "EXCEL NEWS" wrote:
    >
    > > here is my function
    > >
    > > Function SheetName(x) As String '
    > > Application.Volatile
    > > SheetName = ActiveSheet.name
    > > End Function '
    > >
    > > what i want to do is to get the sheet name in in which a cell (like
    > > =SheetName(0)) is in.
    > >
    > > not the. name of ActiveSheet.
    > >
    > > what should i do.
    > >
    > >
    > >
    > >
    > >
    > >



+ 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