Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Rename worksheets of workbook - Error code

Can anybody modify macro below to make it continue running even if it
can't rename a worksheet (sheetname can't take cell content) i.e
rename all other sheets.

Sub Renamesheetloop()
For Each ws In Worksheets
ws.Name = ws.Range("A1").Value
Next ws
End Sub

Thxs

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Rename worksheets of workbook - Error code

Sub Renamesheetloop()
For Each ws In Worksheets
on error resume next
ws.Name = ws.Range("A1").Value
on error goto 0
Next ws
End Sub

or

Sub Renamesheetloop()
For Each ws In Worksheets
on error resume next
ws.Name = ws.Range("A1").Value
if err.number = 0 then
'ok
else
msgbox "rename of sheet: " & ws.name & " failed"
err.clear
end if
on error goto 0
Next ws
End Sub

wrote:

Can anybody modify macro below to make it continue running even if it
can't rename a worksheet (sheetname can't take cell content) i.e
rename all other sheets.

Sub Renamesheetloop()
For Each ws In Worksheets
ws.Name = ws.Range("A1").Value
Next ws
End Sub

Thxs


--

Dave Peterson
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
macro to execute code on all worksheets in workbook Gretta Excel Programming 5 April 5th 07 03:44 PM
Error on opening more than one workbook containing the same code [email protected] Excel Programming 0 December 14th 06 12:25 PM
error code while opening a workbook [email protected] Excel Programming 0 November 28th 05 01:27 PM
Error in VBA code to save workbook pikus Excel Programming 1 April 29th 04 03:21 PM
Run code for multiple worksheets in a workbook & Column Formatting Shaun[_3_] Excel Programming 1 January 7th 04 08:35 PM


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

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

About Us

"It's about Microsoft Excel"