+ Reply to Thread
Results 1 to 5 of 5

Add file name to end of all sheet name

  1. #1

    Add file name to end of all sheet name

    Does anybody has a macro which would add the file name of my active
    workbook to all sheet name of the workbook
    eg if file name is file.xls & sheetA & sheetB & sheetC

    macro will rename sheets as foll:
    sheetA - file (without extension ".xls")
    sheetB - file
    sheetC - file

    thxs


  2. #2

    Re: Add file name to end of all sheet name

    Sub SheetnameANDWorkbook()
    ActiveSheet.Name = ActiveSheet.Name & "-" & Left(ActiveWorkbook.Name,
    Len(ActiveWorkbook.Name) - 4)
    End Sub

    can anybody debug above - as I having error with:
    & "-" &

    Thxs



    [email protected] wrote:
    > Does anybody has a macro which would add the file name of my active
    > workbook to all sheet name of the workbook
    > eg if file name is file.xls & sheetA & sheetB & sheetC
    >
    > macro will rename sheets as foll:
    > sheetA - file (without extension ".xls")
    > sheetB - file
    > sheetC - file
    >
    > thxs



  3. #3
    Norman Jones
    Guest

    Re: Add file name to end of all sheet name

    Hi TransferXXX,

    Try:

    '=============>>
    Public Sub Tester()
    Dim WB As Workbook
    Dim SH As Worksheet
    Dim sStr As String

    Set WB = ActiveWorkbook
    sStr = Left(WB.Name, Len(WB.Name) - 4)

    For Each SH In WB.Worksheets
    SH.Name = SH.Name & " - " & sStr
    Next SH
    End Sub
    '<<=============


    ---
    Regards,
    Norman


    <[email protected]> wrote in message
    news:[email protected]...
    > Does anybody has a macro which would add the file name of my active
    > workbook to all sheet name of the workbook
    > eg if file name is file.xls & sheetA & sheetB & sheetC
    >
    > macro will rename sheets as foll:
    > sheetA - file (without extension ".xls")
    > sheetB - file
    > sheetC - file
    >
    > thxs
    >




  4. #4

    Re: Add file name to end of all sheet name

    thxs work great !!
    Norman Jones wrote:
    > Hi TransferXXX,
    >
    > Try:
    >
    > '=============>>
    > Public Sub Tester()
    > Dim WB As Workbook
    > Dim SH As Worksheet
    > Dim sStr As String
    >
    > Set WB = ActiveWorkbook
    > sStr = Left(WB.Name, Len(WB.Name) - 4)
    >
    > For Each SH In WB.Worksheets
    > SH.Name = SH.Name & " - " & sStr
    > Next SH
    > End Sub
    > '<<=============
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    > <[email protected]> wrote in message
    > news:[email protected]...
    > > Does anybody has a macro which would add the file name of my active
    > > workbook to all sheet name of the workbook
    > > eg if file name is file.xls & sheetA & sheetB & sheetC
    > >
    > > macro will rename sheets as foll:
    > > sheetA - file (without extension ".xls")
    > > sheetB - file
    > > sheetC - file
    > >
    > > thxs
    > >



  5. #5
    Dave Peterson
    Guest

    Re: Add file name to end of all sheet name

    Maybe it's not the hyphen causing the trouble.

    A worksheet name is limited to 31 characters and some characters cannot be used.

    So what's the original name of the worksheet and what's the name of the
    workbook?

    [email protected] wrote:
    >
    > Sub SheetnameANDWorkbook()
    > ActiveSheet.Name = ActiveSheet.Name & "-" & Left(ActiveWorkbook.Name,
    > Len(ActiveWorkbook.Name) - 4)
    > End Sub
    >
    > can anybody debug above - as I having error with:
    > & "-" &
    >
    > Thxs
    >
    > [email protected] wrote:
    > > Does anybody has a macro which would add the file name of my active
    > > workbook to all sheet name of the workbook
    > > eg if file name is file.xls & sheetA & sheetB & sheetC
    > >
    > > macro will rename sheets as foll:
    > > sheetA - file (without extension ".xls")
    > > sheetB - file
    > > sheetC - file
    > >
    > > thxs


    --

    Dave Peterson

+ 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