PC Review


Reply
Thread Tools Rate Thread

1004-Applcation-defined or object-defined error

 
 
=?Utf-8?B?UyBJc2ZlbGQ=?=
Guest
Posts: n/a
 
      24th Oct 2006
Have a function that copies what a user inputs in one cell to the adjacent
cell if certain conditions are met. Works fine when I type the value into
the cell, but when I select the value from a validation list I recieve the
error 1004. Simplified the condition on the code below. When I place a
break on .Value = Target.Value, Target.Value contains the value selected from
the validation list.


Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ERR_CleanUp
Dim i_row As Integer
Dim i_column As Integer

Application.DisplayAlerts = False
Application.EnableEvents = False

i_row = Target.Row
i_column = Target.Column
If Target.Address = "$P$5" Then
With Worksheets(1).Cells(i_row, i_column + 1)
.Value = Target.Value
End With
End If
CleanUp:
Application.DisplayAlerts = True
Application.EnableEvents = True
Exit Sub
ERR_CleanUp:

If Err.Number = 1004 Then
MsgBox "Excel has had a brain fart.", vbInformation
Else
MsgBox Err.Number & "- " & Err.Description
End If
Resume CleanUp
End Sub
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      24th Oct 2006
Try changing $P$5 to Cells(5, 16). That will put your taget and your offset
in the same type cell reference.

"S Isfeld" wrote:

> Have a function that copies what a user inputs in one cell to the adjacent
> cell if certain conditions are met. Works fine when I type the value into
> the cell, but when I select the value from a validation list I recieve the
> error 1004. Simplified the condition on the code below. When I place a
> break on .Value = Target.Value, Target.Value contains the value selected from
> the validation list.
>
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> On Error GoTo ERR_CleanUp
> Dim i_row As Integer
> Dim i_column As Integer
>
> Application.DisplayAlerts = False
> Application.EnableEvents = False
>
> i_row = Target.Row
> i_column = Target.Column
> If Target.Address = "$P$5" Then
> With Worksheets(1).Cells(i_row, i_column + 1)
> .Value = Target.Value
> End With
> End If
> CleanUp:
> Application.DisplayAlerts = True
> Application.EnableEvents = True
> Exit Sub
> ERR_CleanUp:
>
> If Err.Number = 1004 Then
> MsgBox "Excel has had a brain fart.", vbInformation
> Else
> MsgBox Err.Number & "- " & Err.Description
> End If
> Resume CleanUp
> End Sub

 
Reply With Quote
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      24th Oct 2006
Give this a whirl...

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ERR_CleanUp

Application.EnableEvents = False
If Target.Address = "$P$5" Then Target.offset(0,1).Value = Target.Value
CleanUp:
Application.EnableEvents = True
Exit Sub
ERR_CleanUp:

If Err.Number = 1004 Then
MsgBox "Excel has had a brain fart.", vbInformation
Else
MsgBox Err.Number & "- " & Err.Description
End If
Resume CleanUp
End Sub
--
HTH...

Jim Thomlinson


"S Isfeld" wrote:

> Have a function that copies what a user inputs in one cell to the adjacent
> cell if certain conditions are met. Works fine when I type the value into
> the cell, but when I select the value from a validation list I recieve the
> error 1004. Simplified the condition on the code below. When I place a
> break on .Value = Target.Value, Target.Value contains the value selected from
> the validation list.
>
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> On Error GoTo ERR_CleanUp
> Dim i_row As Integer
> Dim i_column As Integer
>
> Application.DisplayAlerts = False
> Application.EnableEvents = False
>
> i_row = Target.Row
> i_column = Target.Column
> If Target.Address = "$P$5" Then
> With Worksheets(1).Cells(i_row, i_column + 1)
> .Value = Target.Value
> End With
> End If
> CleanUp:
> Application.DisplayAlerts = True
> Application.EnableEvents = True
> Exit Sub
> ERR_CleanUp:
>
> If Err.Number = 1004 Then
> MsgBox "Excel has had a brain fart.", vbInformation
> Else
> MsgBox Err.Number & "- " & Err.Description
> End If
> Resume CleanUp
> End Sub

 
Reply With Quote
 
=?Utf-8?B?UyBJc2ZlbGQ=?=
Guest
Posts: n/a
 
      25th Oct 2006
Still the same problem, works fine when I enter the value into the cell but
errors when I pick from the validation list.

"Jim Thomlinson" wrote:

> Give this a whirl...
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> On Error GoTo ERR_CleanUp
>
> Application.EnableEvents = False
> If Target.Address = "$P$5" Then Target.offset(0,1).Value = Target.Value
> CleanUp:
> Application.EnableEvents = True
> Exit Sub
> ERR_CleanUp:
>
> If Err.Number = 1004 Then
> MsgBox "Excel has had a brain fart.", vbInformation
> Else
> MsgBox Err.Number & "- " & Err.Description
> End If
> Resume CleanUp
> End Sub
> --
> HTH...
>
> Jim Thomlinson
>
>
> "S Isfeld" wrote:
>
> > Have a function that copies what a user inputs in one cell to the adjacent
> > cell if certain conditions are met. Works fine when I type the value into
> > the cell, but when I select the value from a validation list I recieve the
> > error 1004. Simplified the condition on the code below. When I place a
> > break on .Value = Target.Value, Target.Value contains the value selected from
> > the validation list.
> >
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > On Error GoTo ERR_CleanUp
> > Dim i_row As Integer
> > Dim i_column As Integer
> >
> > Application.DisplayAlerts = False
> > Application.EnableEvents = False
> >
> > i_row = Target.Row
> > i_column = Target.Column
> > If Target.Address = "$P$5" Then
> > With Worksheets(1).Cells(i_row, i_column + 1)
> > .Value = Target.Value
> > End With
> > End If
> > CleanUp:
> > Application.DisplayAlerts = True
> > Application.EnableEvents = True
> > Exit Sub
> > ERR_CleanUp:
> >
> > If Err.Number = 1004 Then
> > MsgBox "Excel has had a brain fart.", vbInformation
> > Else
> > MsgBox Err.Number & "- " & Err.Description
> > End If
> > Resume CleanUp
> > End Sub

 
Reply With Quote
 
shashisharath.navada@gmail.com
Guest
Posts: n/a
 
      9th Nov 2006

In case of situation like Worksheet("data").Range(variable,what could
be the format of value in variable???

thanks.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Application-Defined or object defined error 1004 When ran on exel97 but not 2003 bornweb Microsoft Excel Programming 0 17th Feb 2007 11:30 PM
Another 1004 Application-defined or Object -defined Error problem DatixRon via OfficeKB.com Microsoft Excel Crashes 3 18th Sep 2006 12:25 PM
RE: Runtime error 1004- application defined or object defined erro =?Utf-8?B?Tm92aWNl?= Microsoft Excel Programming 0 6th Feb 2006 09:34 PM
RE: Runtime error 1004- application defined or object defined erro =?Utf-8?B?Tm92aWNl?= Microsoft Excel Programming 1 6th Feb 2006 09:33 PM
RE: Runtime error 1004- application defined or object defined erro =?Utf-8?B?SmltIFRob21saW5zb24=?= Microsoft Excel Programming 0 6th Feb 2006 09:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:13 PM.