Solved

Run-time error '1004' with a button click

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

803 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