Run-time error '13'

Randomhero180

New Member
Joined
Sep 14, 2011
Messages
44
If any one can help me debug this code that would be awesome.

It all works properly but when I do some things like fill multiple cells anywhere on the sheet I get a

Run-time error '13'
Type-mismatch

Like i said it is not when I am doing anything in the cells that utilize the code, its anywhere, it doesn't prevent me from using it, just annoying for the other people using it.

Code:
Option Explicit
 
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rngData As Range
     
    Set rngData = ActiveSheet.Range("B19:G12679")
     
    If Not Application.Intersect(rngData, Target) Is Nothing Then
        Cells(Target.Row, 8).Value = Now
    End If
    
    If Target.Cells.Value = "Estimate Approved" Then
        Cells(Target.Row, 10).Value = Now
    End If
    
    If Target.Cells.Value = "Contact Sheet Available/Disc Sent" Then
        Cells(Target.Row, 11).Value = Now
    End If
    
    Set rngData = Nothing
     
End Sub

Thanks in advance!

RH
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try removing .Cells

Code:
Option Explicit
 
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rngData As Range
     
    Set rngData = ActiveSheet.Range("B19:G12679")
     
    If Not Application.Intersect(rngData, Target) Is Nothing Then
        Cells(Target.Row, 8).Value = Now
    End If
    
    If Target.Value = "Estimate Approved" Then
        Cells(Target.Row, 10).Value = Now
    End If
    
    If Target.Value = "Contact Sheet Available/Disc Sent" Then
        Cells(Target.Row, 11).Value = Now
    End If
    
    Set rngData = Nothing
     
End Sub
 
Upvote 0
Try like this

Rich (BB code):
Option Explicit
 
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rngData As Range
    If Target.Count > 1 Then Exit Sub
    Set rngData = ActiveSheet.Range("B19:G12679")
 
    If Not Application.Intersect(rngData, Target) Is Nothing Then
        Cells(Target.Row, 8).Value = Now
    'End If  <--Moved this End If to the end...
 
        If Target.Value = "Estimate Approved" Then
            Cells(Target.Row, 10).Value = Now
        End If
 
        If Target.Value = "Contact Sheet Available/Disc Sent" Then
            Cells(Target.Row, 11).Value = Now
        End If
    End If
    Set rngData = Nothing
 
End Sub


Hope that helps.
 
Upvote 0
Glad to help...

Come to think of it, you should probably also turn off Events...

Code:
Option Explicit
 
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngData As Range
If Target.Count > 1 Then Exit Sub
Application.EnableEvents = False
Set rngData = ActiveSheet.Range("B19:G12679")
 
If Not Application.Intersect(rngData, Target) Is Nothing Then
    Cells(Target.Row, 8).Value = Now
 
    If Target.Value = "Estimate Approved" Then
        Cells(Target.Row, 10).Value = Now
    End If
 
    If Target.Value = "Contact Sheet Available/Disc Sent" Then
        Cells(Target.Row, 11).Value = Now
    End If
End If
Set rngData = Nothing
Application.EnableEvents = True
End Sub
 
Upvote 0
if i do that then the last two if statements dont work

Code:
    If Target.Value = "Estimate Approved" Then
        Cells(Target.Row, 10).Value = Now
    End If
 
    If Target.Value = "Contact Sheet Available/Disc Sent" Then
        Cells(Target.Row, 11).Value = Now
    End If

Any the NOW part of the code does not update everytime the cell value changes, which is what I am looking for. The first solution you posted works great.
 
Upvote 0

Forum statistics

Threads
1,224,509
Messages
6,179,192
Members
452,893
Latest member
denay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top