Solved

Run-time error '1004' with a button click

Posted on 2006-06-26
3
179 Views
Last Modified: 2010-04-30
I have a button click with visual basic coding in one sheet. This button calls upon the next sheet along to do some work. This is just a portion of the coding:
sheets(2).activate
range("A1").select
It renders this error: "Run-time error '1004': Application-defined or object-defined error"
However if I copy and paste this into a module it works fine!!!!
What is the problem?????
Thanks
0
Comment
Question by:manukaucouncil
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Author Comment

by:manukaucouncil
ID: 16989496
I need the vb within the current sheet as I will be copying and pasting it into other workbooks (so i need the vb to follow it)......
is the problem that the vb resides in a certain worksheet and cannot access other worksheet's stuff?
0
 
LVL 3

Accepted Solution

by:
gafoorgk earned 500 total points
ID: 16989825
if u want to include your code in a specific sheet u must access range object like following

Sheets(2).Range("A1").Select

this is because if u don't specify the parent object if u r running code from the sheet, sheet will assume Self. If u r running your code in a module, it'll assume active sheet.
0
 
LVL 8

Expert Comment

by:hiteshgupta1
ID: 16989898
have u tried using recorder ?
Try to switch the recorder on
record what u want to do(activate shhet and select range etc.)
and verify it with ur code
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question