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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:46:53+00:00 2026-06-01T01:46:53+00:00

I have done a small project, which consists of 5 excel sheet in, code

  • 0

I have done a small project, which consists of 5 excel sheet in, code is working fine and I am getting exact result also, but if I rename sheets from sheet1 to some other name I am getting Subscript out of range Error.

What is the reason for this and what needs to be done to overcome this. Please help.

Below is the code

Public  Sub amount_final()

Dim Row1Crnt As Long
Dim Row2Crnt As Long


With Sheets("sheet4")
Row1Last = .Cells(Rows.Count, "B").End(xlUp).Row
End With

Row1Crnt = 2
With Sheets("sheet3")
Row2Last = .Cells(Rows.Count, "B").End(xlUp).Row
End With
  • 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-01T01:46:55+00:00Added an answer on June 1, 2026 at 1:46 am

    There is nothing wrong with the code per se. You will get Subscript out of range error if Excel is not able to find a particular sheet which is quite obvious since you renamed it. For example, if you rename your sheet “Sheet3” to “SheetXYZ” then Excel will not be able to find it.

    The only way to avoid these kind of errors is to use CODENAME of the sheets. See Snapshot

    enter image description here

    Here we have a sheet which has a name “Sample Name before Renaming”

    So consider this code

    Sheets("Sample Name before Renaming").Range("A1").Value = "Blah Blah"
    

    The same code can be written as

    Sheet2.Range("A1").Value = "Blah Blah"
    

    Now no matter how many times you rename the sheet, the above code will always work 🙂

    HTH

    Sid

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

Sidebar

Related Questions

I have some small project to stream video to android device. Streaming is done
I have a class Foo which is used in a small standalone project. It
I have done one small project with Zend. This is my second project and
I am currently working on a project which allows users to design a small
I have been working on a project which uses Tiger's SQLite3 library (which if
I'm working on a small C++ project which involves a launcher application that does
I have done a couple of small personal projects in .NET and following the
I'm working on a project which is being used by a number of people
I'd like to get some code editing for a free software project done during
I'm working on a small UML editor project, in Java, that I started a

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.