?
Solved

Run-time error '1004' with a button click

Posted on 2006-06-26
3
Medium Priority
?
181 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…
Suggested Courses

800 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