LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Range Question / error 1004: method Range of object Worksheet has failed

After trying for quite some time I have narrowed down my problem. For the
first time I am using Ranges. I got an example which searches through column
A (set Range = the column) searches for a value which is in cell B1. The
code was on the same sheet, and there is no problem.
But I wanted to search through column A on Sheet1 and search for a value in
a cell in sheet2. I couldn't get it to work. Finally I have got it working
but not like I want to:

Now I have a button on sheet2, Cell D5 on sheet2 contains the value to be
searched on sheet1. But the button now refers to code on a module1 rather
than on the "sheet2 code area" (so to speak).

As long as I use the code in the module1 I don't get any errors but when I
copy the code to sheet2 I get an error 1004.

It is this code that gives the problems on sheet2 and which works fine on
module1:
***
Set AllCells = Range(Worksheets(1).Cells(1, 1), Worksheets(1).Cells(65536,
1).End(xlUp))
***
I have tried to insert Worksheets(1).activate (which I acually wanted to
avoid), but this doesn't change a thing.

How can I get the Set AllCells range to work on the codepage of sheet2
rather than on module1

TIA



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
runtime error 1004 method range of object '_global failed valdesd Excel Discussion (Misc queries) 2 October 6th 05 07:26 PM
Runtime Error 1004 - Method Range of '_Global failed' Sworkhard Excel Programming 3 July 9th 04 04:20 AM
Runime Error 1004 Method Range of Object Global Failed Mohan[_5_] Excel Programming 3 May 21st 04 03:35 PM
"Run-time error '1004'" Method 'Range' of object '_global' failed. haisat[_2_] Excel Programming 0 October 20th 03 12:13 PM
error 1004 Select method of Range class failed J.E. McGimpsey Excel Programming 1 September 12th 03 07:42 PM


All times are GMT +1. The time now is 07:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"