Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 1004-Applcation-defined or object-defined error

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 1004-Applcation-defined or object-defined error

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 1004-Applcation-defined or object-defined error

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 1004-Applcation-defined or object-defined error

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 1004-Applcation-defined or object-defined error


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

thanks.



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
Runtime Error 1004: Application defined or object defined error Access n00b Excel Programming 2 April 5th 06 02:58 AM
Runtime error 1004- application defined or object defined erro Novice Excel Programming 0 February 6th 06 09:34 PM
Runtime error 1004- application defined or object defined erro Novice Excel Programming 1 February 6th 06 09:33 PM
Runtime error 1004- application defined or object defined erro Jim Thomlinson[_5_] Excel Programming 0 February 6th 06 09:29 PM
Macro Run-time Error 1004 Application Defined or Object Defined Error Anddmx Excel Programming 6 June 9th 04 03:40 PM


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