Solved

Run-time error '1004' with a button click

Posted on 2006-06-26
3
180 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

707 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