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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:48:01+00:00 2026-06-13T17:48:01+00:00

I want to name a range in an excel sheet that is created dynamically.

  • 0

I want to name a range in an excel sheet that is created dynamically. I tried following but it is not working.

With oWB
  For intCount = 1 To wbnum1
    .Worksheets.Add(After:=.Worksheets(intCount + 1)) 
    .Sheets(intCount + 1).Name = "Sheet" & intCount.ToString()
    .Sheets(intCount + 1).Cells(19, 2).value = "Sheet" & intCount.ToString
    .Sheets(intCount+1).Range("A1:Z1")
    .Range.Name = "Numbers"
  Next

what is wrong with this?

Thanks

  • 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-13T17:48:03+00:00Added an answer on June 13, 2026 at 5:48 pm

    You aren’t specifying a Range.

    Presumably, you should merge your last and second to last line:

    .Sheets(intCount+1).Range("A1:Z1").Name = "Numbers"
    

    However, from experimentation it appears that assigning the name this way creates workbook level names resulting in only the last assignment being valid after you loop through your worksheets.

    An alternate/safer way to do this is to add the name as a worksheet specific name via the worksheet’s names collection:

    .Sheets(intCount+1).Names.Add "Numbers", .Sheets(intCount+1).Range("A1:Z1")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In an Excel worksheet, I have a range name LOOPBACK_IP. I want to programmatically
I have a working excel vba macro that does what I want from here
I want to display: Name [Textbox] Age: [Textbox] BlahBlahCatfish: [Textbox] but if I simply
How do I copy a range of cells from Excel to Powerpoint. I want
I have 2 questions. I want to clear a range of cells in Excel
I'm using the following script to produce buttons in excel, the range is just
I want to scan an excel sheet, and replace any occurrences of social security
Using: Excel 2007/Win 7 First, I created a subroutine to find the dynamic range
We have an asp.net c# program that reads a sheet from an Excel file
I have the following problem in an Excel table. I want to have the

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.