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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:05:31+00:00 2026-05-24T06:05:31+00:00

I have 2 Sub() Functions in Excel. Both have different names but same code.

  • 0

I have 2 Sub() Functions in Excel. Both have different names but same code. but when trying to run together gives an ‘Application defined’ error. Am not able to understand where the problem is

Following is the code for the same

Sub GT456T()

Sheets("Sheet2").Rows("1:1").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
Rows("11:11").Select
ActiveSheet.Paste

End Sub



Sub CopyRecord()


Sheets("Sheet2").Rows("1:1").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
Rows("11:11").Select
 ActiveSheet.Paste
End Sub

I dont understand why does it give error when run one after one another. if i run the 1st macro it doesnt throw an error but when executing the second immediately after the first it throw an ‘Application defined’ error. please help

  • 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-24T06:05:32+00:00Added an answer on May 24, 2026 at 6:05 am

    Without more details about the problem, this is guesswork, but here’s my shot at it:

    The .Select method only works on ranges whose parent sheet is currently active. When you run either macro once, Sheet1 ends up being the active sheet when it’s done running. Then you try to run either macro again “immediately” after the first, and the macro wants to select something on Sheet2, but Sheet2 isn’t active. Sheet1 is. So you get an error.

    There, that was my best, most educated guess.

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

Sidebar

Related Questions

I have the same issue as in Excel VBA: Parsed JSON Object Loop but
I have an application in vb.net that starts with a sub function do some
This is the code I have: Sub Main() Dim dts As New DataSet Dim
We have a sub-project 'commonUtils' that has many generic code-snippets used across the parent
I have some fairly old code that runs just fine in Excel versions before
I have: Public Class ExcelProcess Private App As New Excel.Application Private Books As Excel.Workbooks
I have a customer trying to use a 75mb Excel spreadsheet as a database.
I am (unfortunately) developing an application in Excel 2000 VBA. I believe I have
I have this function in my generator. Private Sub AddBoundedValue(ByVal boundedValue As Object, ByVal
I have classX: Sub New(ByVal item_line_no As String, ByVal item_text As String) ' check

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.