Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code within a sheet

Status
Not open for further replies.

Ca1icoJack

IS-IT--Management
Nov 27, 2008
36
GB
I have been trying to create some code behind a command button in a worksheet. When it is clicked it links to another sheet and collects data which it then uses to create a graph. I always get an error:
___________________________________________
Runtime Error '1004':

Application-Defined or Object-Defined Error
___________________________________________

The line of code it occurs on is just Range("X8").Select.

I'm assuming that this is because code in a sheet cannot gather data from other sheets?

If this is the case is there a way to retain a macro when copying some sheets to a new workbook? Since my code imports text files and converts them to an output sheet which is then exported.
 
Qualify the Range with a Sheet object, eg:
Sheets("your sheet name").Range("X8").Select

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks. This works fine for the data copying bit, but doesn't work when I'm trying to select a range for a graph. Any ideas?
 
Sorry, nevermind, it seems to be working now that I've re-run it. I don't know why since I didn't change anything.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top