Solved

Run-time error '1004' with a button click

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now