#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default 1004 error

I have the following piece of code. The Msgbox prints correctly, whereas the
very next line gives the error:
1004: Application defined or object-defined error


Private Sub Worksheet_Change(ByVal Target As Range)

myRow = Target.Row
MsgBox Cells(myRow, "E") ' prints the message
correctly.
Cells(myRow, "E") = "=$E$3" ' throws the error


Anybody has any idea why I am getting this error.


--
- Mangesh
------------------------------------------
Office 2003 & Windows XP


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

forgot to mention something. The cell I am changing has a list validation.
If I change it manually, no error, whereas if I change it by clicking on the
drop-down list (data validation), I get the error.

Mangesh


"Mangesh Yadav" wrote in message
...
I have the following piece of code. The Msgbox prints correctly, whereas

the
very next line gives the error:
1004: Application defined or object-defined error


Private Sub Worksheet_Change(ByVal Target As Range)

myRow = Target.Row
MsgBox Cells(myRow, "E") ' prints the message
correctly.
Cells(myRow, "E") = "=$E$3" ' throws the error


Anybody has any idea why I am getting this error.


--
- Mangesh
------------------------------------------
Office 2003 & Windows XP




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default 1004 error

Mangesh,

I tried your code - it did not give any error. It kept redisplaying the
message box since you do not turn off the Application.EnableEvents property
before making a change.

Also just some comments on your code .. it is preferable to not use Cells -
as that is an unqualified reference and has given me some problems in the
past.

With ActiveSheet (or a specific sheet)
.Cells(....)
end with

is preferable.

Alok

"Mangesh Yadav" wrote:

forgot to mention something. The cell I am changing has a list validation.
If I change it manually, no error, whereas if I change it by clicking on the
drop-down list (data validation), I get the error.

Mangesh


"Mangesh Yadav" wrote in message
...
I have the following piece of code. The Msgbox prints correctly, whereas

the
very next line gives the error:
1004: Application defined or object-defined error


Private Sub Worksheet_Change(ByVal Target As Range)

myRow = Target.Row
MsgBox Cells(myRow, "E") ' prints the message
correctly.
Cells(myRow, "E") = "=$E$3" ' throws the error


Anybody has any idea why I am getting this error.


--
- Mangesh
------------------------------------------
Office 2003 & Windows XP





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default 1004 error

Hi Alok,

Thanks for the response. Actually I am close to isolating the error. I have
one UDF which if not used in a particular cell, then the error does not
come.

Also, the error comes only when I choose an item by selecting it with the
mouse, and no error when entering manually in the cell.

Mangesh




"Alok" wrote in message
...
Mangesh,

I tried your code - it did not give any error. It kept redisplaying the
message box since you do not turn off the Application.EnableEvents

property
before making a change.

Also just some comments on your code .. it is preferable to not use

Cells -
as that is an unqualified reference and has given me some problems in the
past.

With ActiveSheet (or a specific sheet)
.Cells(....)
end with

is preferable.

Alok

"Mangesh Yadav" wrote:

forgot to mention something. The cell I am changing has a list

validation.
If I change it manually, no error, whereas if I change it by clicking on

the
drop-down list (data validation), I get the error.

Mangesh


"Mangesh Yadav" wrote in message
...
I have the following piece of code. The Msgbox prints correctly,

whereas
the
very next line gives the error:
1004: Application defined or object-defined error


Private Sub Worksheet_Change(ByVal Target As Range)

myRow = Target.Row
MsgBox Cells(myRow, "E") ' prints the message
correctly.
Cells(myRow, "E") = "=$E$3" ' throws the error


Anybody has any idea why I am getting this error.


--
- Mangesh
------------------------------------------
Office 2003 & Windows XP







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, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 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 01:03 AM.

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

About Us

"It's about Microsoft Excel"