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 7079211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:38:37+00:00 2026-05-28T06:38:37+00:00

The script below loops through to create tabs and name the tab then it

  • 0

The script below loops through to create tabs and name the tab then it will place the tab name in cell B3. It’s been working fine but now gives the catch all runtime error 1004. At the bottom of my script it renames the tab. This is where the error is happening. It’s creating the tabs but fails to rename it. Can anyone please suggest another way to rename the tab in this script. The error is on Sheets(Name).Select.

Public Sub CreateTabs()
  Sheets("TABlist").Select
  ' Determine how many Names are on Data sheet
  FinalRow = Range("A65000").End(xlUp).Row
  ' Loop through each Name on the data sheet
  For x = 1 To FinalRow
    LastSheet = Sheets.Count
    Sheets("TABlist").Select
    Name = Range("A" & x).Value
    ' Make a copy of FocusAreas and move to end
    Sheets("TABshell").Copy After:=Sheets(LastSheet)
    ' rename the sheet and put name in Cell B2
    Sheets(LastSheet + 1).Name = Name
    Sheets(Name).Select
    Range("B3").Value = Name
  Next x 
End Sub
  • 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-05-28T06:38:38+00:00Added an answer on May 28, 2026 at 6:38 am

    I got lost amid all the selects so I am not sure why your original code failed. I edited your question to make it more readable but only I can see the improvement until my edit it peer reviewed.

    I have deleted all your select statements. Comments starting ‘## explain why I have made other changes.

    Option Explicit
    Public Sub CreateTabs()
    
       Dim CrntRow As Long              '## I like names I understand
       Dim FinalRow As Long
       Dim Name As String
    
       ' Determine how many Names are on Data sheet
       '## Row.Count will work for any version of Excel
       FinalRow = Sheets("TABlist").Cells(Rows.Count, "A").End(xlUp).Row
       ' Loop through each Name on the data sheet
       For CrntRow = 1 To FinalRow
         Name = Sheets("TABlist").Range("A" & CrntRow).Value
         ' Make a copy of FocusAreas and move to end
         Sheets("TABshell").Copy After:=Sheets(Worksheets.Count)
         ' rename the sheet and put name in Cell B2
         '## The copy will be the active sheet
         With ActiveSheet
           .Name = Name
           .Range("B3").Value = Name
         End With
       Next CrntRow
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working with MVC3, Razor, Jquery, Javascript. The below code loops through and displays a
I have a Perl script which nests foreach loops as seen below. It takes
The script below will replace selected word in a textarea. But it only works
Consider the script below. It will launch two subprocesses, each one a CherryPy app
I am trying to create a batch script for my Windows machine that loops
I have a bash shell script that loops through all child directories (but not
I have a php script that steps through a folder containing tab delimited files,
I have python code below that will loop through a table and print out
I have the following script which I am running. It loops through each table
I have a script snippet looks like below: <ItemGroup> <files Include=*.txt></files> </ItemGroup> <Message Text=@(files)>

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.