Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Renaming Worksheets

Use the left function to remove the last four

ActiveSheet.Name = Left(mybook.Name, Len(mybook.Name) - 4)



--
Regards Ron de Bruin
http://www.rondebruin.nl


"tcgaines" wrote in message
...

After combining worksheets from different workbooks, the name of the
worksheets, by default, is the name of the workbook, ie: products.xls.
There are many worksheets. I want to implement a loop that will will
remove ".xls" from each of the worksheet names. any thoughts?

Thanks.


--
tcgaines
------------------------------------------------------------------------
tcgaines's Profile: http://www.excelforum.com/member.php...o&userid=29608
View this thread: http://www.excelforum.com/showthread...hreadid=493879



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Renaming Worksheets

Hi TC,

This is not default behaviour but is, I suspect, caused by the code used to
combine the workbooks.

Try:

'=============
Public Sub Tester()
Dim WB As Workbook
Dim sh As Worksheet

Set WB = ActiveWorkbook '<<==== CHANGE

For Each sh In WB.Worksheets
If LCase(Right(sh.Name, 4)) = ".xls" Then
sh.Name = Left(sh.Name, Len(sh.Name) - 4)
End If
Next

End Sub
'<<=============


---
Regards,
Norman


"tcgaines" wrote in
message ...

After combining worksheets from different workbooks, the name of the
worksheets, by default, is the name of the workbook, ie: products.xls.
There are many worksheets. I want to implement a loop that will will
remove ".xls" from each of the worksheet names. any thoughts?

Thanks.


--
tcgaines
------------------------------------------------------------------------
tcgaines's Profile:
http://www.excelforum.com/member.php...o&userid=29608
View this thread: http://www.excelforum.com/showthread...hreadid=493879



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Renaming Worksheets

Give the following a try:

Sub renameWS()
Dim ws As Worksheet
For Each ws In Worksheets
If Right(CStr(ws.Name), 4) = ".xls" Then
ws.Name = Left(CStr(ws.Name), Len(ws.Name) - 4)
End If
Next ws
End Sub

HTH--Lonnie M.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Renaming Worksheets

This line you must use in the macro from the other thread

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Ron de Bruin" wrote in message ...
Use the left function to remove the last four

ActiveSheet.Name = Left(mybook.Name, Len(mybook.Name) - 4)



--
Regards Ron de Bruin
http://www.rondebruin.nl


"tcgaines" wrote in message
...

After combining worksheets from different workbooks, the name of the
worksheets, by default, is the name of the workbook, ie: products.xls.
There are many worksheets. I want to implement a loop that will will
remove ".xls" from each of the worksheet names. any thoughts?

Thanks.


--
tcgaines
------------------------------------------------------------------------
tcgaines's Profile: http://www.excelforum.com/member.php...o&userid=29608
View this thread: http://www.excelforum.com/showthread...hreadid=493879





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Renaming Worksheets


After combining worksheets from different workbooks, the name of the
worksheets, by default, is the name of the workbook, ie: products.xls.
There are many worksheets. I want to implement a loop that will will
remove ".xls" from each of the worksheet names. any thoughts?

Thanks.


--
tcgaines
------------------------------------------------------------------------
tcgaines's Profile: http://www.excelforum.com/member.php...o&userid=29608
View this thread: http://www.excelforum.com/showthread...hreadid=493879



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Renaming Worksheets


Thank you all for your input. Lonnie, gave your take a run and it
worked perfectly.

:]


--
tcgaines
------------------------------------------------------------------------
tcgaines's Profile: http://www.excelforum.com/member.php...o&userid=29608
View this thread: http://www.excelforum.com/showthread...hreadid=493879

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Renaming worksheets James Excel Worksheet Functions 0 May 12th 09 11:45 PM
RENAMING WORKSHEETS LEOPARDSHIDEAWAY Excel Worksheet Functions 1 July 26th 07 10:27 PM
Renaming Worksheets Steve Walford Excel Worksheet Functions 3 April 1st 05 09:29 PM
Renaming Worksheets rbanks[_10_] Excel Programming 2 June 16th 04 11:51 PM
Renaming worksheets! aiyer[_3_] Excel Programming 3 February 20th 04 12:09 AM


All times are GMT +1. The time now is 09:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"