Type Mismatch Run Time Error with Code when deleting multiple cells contents

DCCC93

New Member
Joined
Jan 22, 2016
Messages
20
Hi all,

I've been using the below code to automatically enter today's date in column b when entering anything into column a - which has been working perfectly.

Private Sub Worksheet_Change(ByVal Target As Range)
' If you update a cell in column A with a value and there is no date in the corresponding row of column B then
If Not Intersect(Target, Range("A:A")) Is Nothing And Target.Value <> "" And Range("B" & Target.Row).Value = "" Then
' Insert today's date in the corresponding row of column B
Range("B" & Target.Row).Value = Date
' Else if you remove the value from a cell in column A then
ElseIf Not Intersect(Target, Range("A:A")) Is Nothing And Target.Value = "" And Range("B" & Target.Row).Value <> "" Then
' Clear the value from the corresponding row of column B
Range("B" & Target.Row).ClearContents
End If
End Sub


However, I've just noticed that when I delete the contents of multiple cells at one time anywhere in the worksheet I get a Run Time Error 13 - Type Mismatch.

It highlights the second line If Not Intersect(Target, Range("A:A")) Is Nothing And Target.Value <> "" And Range("B" & Target.Row).Value = "" Then in the debugger so is it something to do with the Target part?

I can't work out how to correct it and wondered if anyone might know?

Thanks
DC
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,222,827
Messages
6,168,482
Members
452,192
Latest member
FengXue

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