Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 193
Default Wrong with macro naming sheets

Hi!

I get an error when using this macro! What is the problem? Ive marked it
below where it gives me the error!

Thanks for all the help!

Sub MonthlySentOut()

Cells.Select
Selection.Interior.ColorIndex = xlNone
Range("B1").Select
Selection.ClearContents
Range("B11").Select
Selection.ClearContents
Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=MID(R[6]C[1],28,7)"
Range("A2").Select
For Each Sh In ActiveWorkbook.Sheets
Sh.Activate
Sh.Name = Cells(1, 1).Value <---- where error occurs!!!!
Next Sh
sPath = "C:\Temp\"
ActiveWorkbook.SaveAs sPath & ActiveSheet.Range("a1").Value
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 301
Default Wrong with macro naming sheets

One guess is that =MID(B7,28,7) gets its value from B7 on one of the sheets
which results in either empty or invalid characters for a sheet name.
"Pete" wrote in message
...
Hi!

I get an error when using this macro! What is the problem? Ive marked it
below where it gives me the error!

Thanks for all the help!

Sub MonthlySentOut()

Cells.Select
Selection.Interior.ColorIndex = xlNone
Range("B1").Select
Selection.ClearContents
Range("B11").Select
Selection.ClearContents
Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=MID(R[6]C[1],28,7)"
Range("A2").Select
For Each Sh In ActiveWorkbook.Sheets
Sh.Activate
Sh.Name = Cells(1, 1).Value <---- where error

occurs!!!!
Next Sh
sPath = "C:\Temp\"
ActiveWorkbook.SaveAs sPath & ActiveSheet.Range("a1").Value
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default Wrong with macro naming sheets


The following characters are not valid characters to use in worksheet
names:
/ ? * [ ]

http://support.microsoft.com/kb/q213900/

Pete wrote:
Hi!

I get an error when using this macro! What is the problem? Ive marked it
below where it gives me the error!

Thanks for all the help!

Sub MonthlySentOut()

Cells.Select
Selection.Interior.ColorIndex = xlNone
Range("B1").Select
Selection.ClearContents
Range("B11").Select
Selection.ClearContents
Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=MID(R[6]C[1],28,7)"
Range("A2").Select
For Each Sh In ActiveWorkbook.Sheets
Sh.Activate
Sh.Name = Cells(1, 1).Value <---- where error occurs!!!!
Next Sh
sPath = "C:\Temp\"
ActiveWorkbook.SaveAs sPath & ActiveSheet.Range("a1").Value
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Wrong with macro naming sheets

You can also simplify the code

Sub MonthlySentOut()

Cells.Interior.ColorIndex = xlNone
Range("B1,B11").ClearContents
Range("A1").FormulaR1C1 = "=MID(R[6]C[1],28,7)"
For Each sh In ActiveWorkbook.Sheets
sh.Name = sh.Cells(1, 1).Value
Next sh
sPath = "C:\Temp\"
ActiveWorkbook.SaveAs sPath & ActiveSheet.Range("a1").Value
End Sub



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Bob Umlas" wrote in message
...
One guess is that =MID(B7,28,7) gets its value from B7 on one of the

sheets
which results in either empty or invalid characters for a sheet name.
"Pete" wrote in message
...
Hi!

I get an error when using this macro! What is the problem? Ive marked it
below where it gives me the error!

Thanks for all the help!

Sub MonthlySentOut()

Cells.Select
Selection.Interior.ColorIndex = xlNone
Range("B1").Select
Selection.ClearContents
Range("B11").Select
Selection.ClearContents
Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=MID(R[6]C[1],28,7)"
Range("A2").Select
For Each Sh In ActiveWorkbook.Sheets
Sh.Activate
Sh.Name = Cells(1, 1).Value <---- where error

occurs!!!!
Next Sh
sPath = "C:\Temp\"
ActiveWorkbook.SaveAs sPath & ActiveSheet.Range("a1").Value
End Sub





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
Naming sheets from a cell value Tony4X4 Excel Discussion (Misc queries) 12 September 7th 09 01:55 PM
VBA Help naming sheets jlclyde Excel Discussion (Misc queries) 8 November 20th 07 09:59 PM
Macro for naming sheets? Olle Svensson Excel Discussion (Misc queries) 1 August 3rd 06 03:41 PM
What is wrong with naming a cell as c? vezerid Excel Discussion (Misc queries) 4 January 31st 06 08:57 PM
naming sheets Christian Galbavy Excel Programming 2 May 16th 05 10:36 AM


All times are GMT +1. The time now is 07:20 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"