• Extract Sheet Name From Formula (Office 2000-2003)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Extract Sheet Name From Formula (Office 2000-2003)

    • This topic has 8 replies, 3 voices, and was last updated 19 years ago.
    Author
    Topic
    #432019

    Is there a way to extract the sheet name from a formula such as +’Sheetname’!A1? I’ve tried variations of =Left, Right, and Mid but I always end up with the portion of the solution rather than the text embedded in the formula.

    TIA

    Viewing 1 reply thread
    Author
    Replies
    • #1012566

      Can I ask the purpose?

      • #1012568

        I have a sheet that summarizes a cell from many tabs. The tab name happens to be the Dept. # – which is information I need.

    • #1012569

      You would have to use a User Defined Function. A UDF can extract the formula from a cell and work on it. The formula in the cell would have to be consistent enough for the UDF to be able to find the sheet name in the formula. I could help with the UDF, but would have to know exactly what the formula looked like.

      • #1012571

        The formula is +’Sheetname’!A1 where sheetname is 5-digits – i.e. 10100, 15000, 23100 etc. I would like to end up with a column next to the formula showing the text 10100 etc. Am I making sense? 10100 etc. is a department name/number to me and I need that info along with the $ for that department.

        • #1012579

          Does this give you what you want:


          Public Function GetDept(oCell As Range) As String
          Dim strWk As String
          If oCell.HasFormula Then
          strWk = oCell.Formula
          If InStr(strWk, "!") > 0 Then
          GetDept = Mid(strWk, InStr(strWk, "!") - 6, 5)
          Else
          GetDept = CVErr(2001)
          End If
          Else
          GetDept = CVErr(2001)
          End If
          End Function

          Use like this:


          =GETDEPT(A1)

          where A1 is the cell containing the formula.

    Viewing 1 reply thread
    Reply To: Extract Sheet Name From Formula (Office 2000-2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: