Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to strip away "Sheet" prefix from names

Looking for a sub which can strip away the "Sheet" prefix from all sheets
bearing such names, eg sheets named as: Sheet2, Sheet3, Sheet4 ... will be
renamed as simply: 2,3,4 ... Thanks.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Sub to strip away "Sheet" prefix from names

Hi Max,

Try something like:

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

Set WB = Workbooks("MyBook.xls") '<<==== CHANGE

For Each SH In WB.Worksheets
With SH
If UCase(.Name) Like "SHEET*" Then
.Name = Replace(.Name, "Sheet", _
vbNullString, 1, 1, vbTextCompare)
End If
End With
Next SH
End Sub
'<<=============


---
Regards,
Norman


"Max" wrote in message
...
Looking for a sub which can strip away the "Sheet" prefix from all sheets
bearing such names, eg sheets named as: Sheet2, Sheet3, Sheet4 ... will be
renamed as simply: 2,3,4 ... Thanks.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---



  #3   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to strip away "Sheet" prefix from names

Norman,
Many thanks. Runs great !

Set WB = Workbooks("Test1a.xls") '<<==== CHANGE

Just one question, how could your sub be generalized
to run on all books open simultaneously in the same Excel session ?
(hopefully the filenames need not be specified)

Thanks
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Sub to strip away "Sheet" prefix from names

Hi Max,

'------------------
Set WB = Workbooks("Test1a.xls") '<<==== CHANGE

Just one question, how could your sub be generalized
to run on all books open simultaneously in the same Excel session ?
(hopefully the filenames need not be specified)
'------------------

Try:

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

For Each WB In Application.Workbooks
For Each SH In WB.Worksheets
With SH
If UCase(.Name) Like "SHEET*" Then
.Name = Replace(.Name, "Sheet", _
vbNullString, 1, 1, vbTextCompare)
End If
End With
Next SH
Next WB
End Sub
'<<=============



---
Regards,
Norman


  #5   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to strip away "Sheet" prefix from names

Marvellous, Norman !
Thanks
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---


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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
How to prefix "2" to every cell in a column Chirag Dedhia Excel Discussion (Misc queries) 3 April 24th 06 07:31 PM
Please add a "sheet" function like "row" and "column" functions Spreadsheet Monkey Excel Programming 2 November 8th 05 04:08 PM
"Strip" Cell Formula al Excel Programming 2 October 5th 05 10:42 PM
Backup to specific folder if workbook names begins with "NSR" or "MAC" GregR Excel Programming 3 May 6th 05 12:24 AM


All times are GMT +1. The time now is 11:39 AM.

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"