ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add file name to end of all sheet name (https://www.excelbanter.com/excel-programming/366922-add-file-name-end-all-sheet-name.html)

[email protected]

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


[email protected]

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



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



Norman Jones

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


wrote in message
oups.com...
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




[email protected]

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


wrote in message
oups.com...
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

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?

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

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


All times are GMT +1. The time now is 07:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com