Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default run time error 1004


when i run the code given below, sometimes i get "error 1004, select method
of range class failed"
error comes in line Sheet8.Range("M5").Select
interesting thing is i get this error only some of the time.
when i am running this module independently, no error comes.
when i call this module from some other module then the error comes.
this code resides in module and the code from which i call for this module
is also written in module (none are in sheet)

please help!!

regards
pradip


Public Sub RevertMod()
'
' Revert Macro
' Macro recorded 4/20/2005 by 112968
'

'
Dim Days As Integer
Days = Sheet8.Range("B1")
Sheet8.Range("M5").Select
ActiveCell.Offset(Days, 0).Range("A1").Select
ActiveCell.GoalSeek Goal:=Sheet8.Range("j1"), ChangingCell:=Sheet8.Range("J2")
Sheet8.Range("A1").Select
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default run time error 1004

sometimes i also get application-defined or object-defined error on line
Sheet8.Range("M5").Select

"Pradip Jain" wrote:


when i run the code given below, sometimes i get "error 1004, select method
of range class failed"
error comes in line Sheet8.Range("M5").Select
interesting thing is i get this error only some of the time.
when i am running this module independently, no error comes.
when i call this module from some other module then the error comes.
this code resides in module and the code from which i call for this module
is also written in module (none are in sheet)

please help!!

regards
pradip


Public Sub RevertMod()
'
' Revert Macro
' Macro recorded 4/20/2005 by 112968
'

'
Dim Days As Integer
Days = Sheet8.Range("B1")
Sheet8.Range("M5").Select
ActiveCell.Offset(Days, 0).Range("A1").Select
ActiveCell.GoalSeek Goal:=Sheet8.Range("j1"), ChangingCell:=Sheet8.Range("J2")
Sheet8.Range("A1").Select
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default run time error 1004

You can only select a cell on a sheet that's selected.

so maybe adding:
sheet8.select
at the top of your routine would fix the problem

(and when you ran the code by hand, maybe that sheet8 was active--just by
coincidence.

Pradip Jain wrote:

sometimes i also get application-defined or object-defined error on line
Sheet8.Range("M5").Select

"Pradip Jain" wrote:


when i run the code given below, sometimes i get "error 1004, select method
of range class failed"
error comes in line Sheet8.Range("M5").Select
interesting thing is i get this error only some of the time.
when i am running this module independently, no error comes.
when i call this module from some other module then the error comes.
this code resides in module and the code from which i call for this module
is also written in module (none are in sheet)

please help!!

regards
pradip


Public Sub RevertMod()
'
' Revert Macro
' Macro recorded 4/20/2005 by 112968
'

'
Dim Days As Integer
Days = Sheet8.Range("B1")
Sheet8.Range("M5").Select
ActiveCell.Offset(Days, 0).Range("A1").Select
ActiveCell.GoalSeek Goal:=Sheet8.Range("j1"), ChangingCell:=Sheet8.Range("J2")
Sheet8.Range("A1").Select
End Sub



--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default run time error 1004

By chance when you get the run time 1004 error, is the active sheet
Sheet8. Using the Immediate window, if the active sheet is not Sheet8 I
get the same error, but if the activesheet is Sheet8 it works perfectly.
I would add a line to like Sheet8.Activate. See if that helps, or you
could add some error trapping, say On Error GoTo ErrorHandler, then in
the ErrorHandler, have the Sheet8.Activate.



*** Sent via Developersdex http://www.developersdex.com ***
Reply
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
Run time error 1004 cinvic Excel Discussion (Misc queries) 3 February 19th 06 12:27 AM
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM
Run time error '1004': Generaol ODBC error Dwaine Horton[_3_] Excel Programming 2 April 26th 05 02:52 PM
Run time error 1004 General ODCB Error Kevin Excel Programming 3 February 26th 05 12:51 PM
Application Run Time Error 1004 and Stack Error ExcelMonkey[_190_] Excel Programming 9 February 11th 05 04:48 PM


All times are GMT +1. The time now is 07:16 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"