Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Excel 2010 Rename sheets if not called Summary

Posted on 2014-01-08
7
Medium Priority
?
276 Views
Last Modified: 2014-01-08
Could someone provide me with VBA code to rename sheets Sheet1, Sheet2 etc that are not already named Summary

Thanks
0
Comment
Question by:Jagwarman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 3

Assisted Solution

by:Sreeram
Sreeram earned 1000 total points
ID: 39764870
HI Jagwarman,

Try this:

Sub Macro1()
    Dim I As Integer
        For I = 1 To Application.ActiveWorkbook.Worksheets.Count
            If Application.ActiveWorkbook.Sheets(I).Name <> "Summary" Then
                Application.ActiveWorkbook.Sheets(I).Name = "Give_Your_Sheet_Name"
            End If
        Next
           
End Sub
0
 
LVL 35

Expert Comment

by:Norie
ID: 39764874
Rename them to what?
0
 
LVL 53

Expert Comment

by:Rgonzo1971
ID: 39764933
HI,

This code preserves the sheets named Sheet1, Sheet2, etc

Sub macro()
ShIndex = 0
    For Each sh In ThisWorkbook.Worksheets
        If sh.Name <> "Summary" And Not (sh.Name Like "Sheet[1-9]") And Not (sh.Name Like "Sheet[1-9][0-9]") Then
        Do
            Set TestSheet = Nothing
            ShIndex = ShIndex + 1
            On Error Resume Next
            Set TestSheet = Sheets("Sheet" & ShIndex)
            On Error GoTo 0
        Loop While Not (TestSheet Is Nothing)
        sh.Name = "Sheet" & ShIndex
        ShIndex = 0
        End If
    Next
End Sub

Open in new window

Regards
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Jagwarman
ID: 39765128
it must be me because I cannot get this to work
0
 

Author Comment

by:Jagwarman
ID: 39765133
Ah this has to be in the Workbook that I have opened to work.
0
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 1000 total points
ID: 39765144
pls try
Sub macro()
ShIndex = 0
    For Each sh In ActiveWorkbook.Worksheets
        If sh.Name <> "Summary" And Not (sh.Name Like "Sheet[1-9]") And Not (sh.Name Like "Sheet[1-9][0-9]") Then
        Do
            Set TestSheet = Nothing
            ShIndex = ShIndex + 1
            On Error Resume Next
            Set TestSheet = Sheets("Sheet" & ShIndex)
            On Error GoTo 0
        Loop While Not (TestSheet Is Nothing)
        sh.Name = "Sheet" & ShIndex
        ShIndex = 0
        End If
    Next
End Sub 

Open in new window

0
 

Author Closing Comment

by:Jagwarman
ID: 39765567
Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question