Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7842103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:14:32+00:00 2026-06-02T16:14:32+00:00

I am naming sheets using : arrayCollabName = Array(CBDeltaBlockStatus_SAP03_to_Delta01, CBDeltaBlockStatus_SAP03_to_Delta02, CBDeltaDeliveryInformation_SAP03_to_Delta01) If Len(arrayCollabName(idx)) >

  • 0

I am naming sheets using :

            arrayCollabName = Array("CBDeltaBlockStatus_SAP03_to_Delta01", "CBDeltaBlockStatus_SAP03_to_Delta02", "CBDeltaDeliveryInformation_SAP03_to_Delta01") 

            If Len(arrayCollabName(idx)) > 31 Then
                 ActiveSheet.Name = Left(arrayCollabName(idx), 31)
            Else
                 ActiveSheet.Name = arrayCollabName(idx)
            End If

In the array 1st and 2nd names are similar when the name gets truncated to 31 characters and VB is throwing the error “Cannot rename the sheet to the same name as another sheet, a referenced object library or a workbook referenced by visualbasic.”

Any way I can do this without error and name the sheets as CBDeltaBlock_SAP03_to_Delta01 and CBDeltaBlock_SAP03_to_Delta02 or any desired name.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:14:32+00:00Added an answer on June 2, 2026 at 4:14 pm

    Here is an example to change the sheet name if it already exists.

    Option Explicit
    
    Sub Sample()
        Dim i As Long
        Dim strShName As String
    
        strShName = "BlahBlah"
    
        Sheets.Add
    
        Do Until DoesSheetExist(strShName) = False
            i = Int((1000 * Rnd) + 1)
            strShName = strShName & i
        Loop
    
        ActiveSheet.Name = strShName
    End Sub
    
    Function DoesSheetExist(ByVal strSheetName As String) As Boolean
        Dim ws As Worksheet
        On Error Resume Next
        Set ws = Sheets(strSheetName)
        On Error GoTo 0
        If Not ws Is Nothing Then DoesSheetExist = True
    End Function
    

    The above method will add a random number at the end of the sheet. If you want in increasing order then use the below code.

    Option Explicit
    
    Sub Sample()
        Dim i As Long
        Dim strShName As String
    
        strShName = "BlahBlah"
    
        Sheets.Add
    
        If DoesSheetExist(strShName) = True Then
            i = 1
            Do Until DoesSheetExist(strShName & i) = False
                i = i + 1
            Loop
            strShName = strShName & i
        End If
    
        ActiveSheet.Name = strShName
    End Sub
    
    Function DoesSheetExist(ByVal strSheetName As String) As Boolean
        Dim ws As Worksheet
        On Error Resume Next
        Set ws = Sheets(strSheetName)
        On Error GoTo 0
        If Not ws Is Nothing Then DoesSheetExist = True
    End Function
    

    NOTE: The above code are just sample codes. Error Handling has not been incorporated in the above code and needless to say that Error handling is a must 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Naming classes is sometimes hard. What do you think name of the class should
What naming conventions are you using for namespaces and sponsor classes? (i.e. the classes
What is your naming convention for DATETIME columns (in my case, using MS SQL
Is there a naming convention or maybe some guideline on how to name function
I am currently automatically naming my tables in fluent NHibernate by using AutoMappingOverride's and
What is your naming conventions of Field Name.. Which is popular way? Example: firstname
When I'm naming array-type variables, I often am confronted with a dilemma: Do I
I am unclear on the naming rules for Actions using stadard routing, etc, in
Which type of naming is better to use in XAML: xmlns:inventoryControls=clr-namespace:Inventory.Components.Controls;assembly=Inventory.Components Then use it
I am concerned with using CSS classes that are defined in style sheets with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.