run time error 13 type mismatch when clearing multiple cells

hotwhls55

New Member
Joined
Jul 15, 2011
Messages
8
Hello All - First time Poster here, name is Tim.

I've been working on building an Excel document, when based on user input into a certain cell, prompts them for information and places received information in a cell. I have all that working to my liking, however, I'm getting stuck on a Run Tim Error 13 Type mismatch when I clear the multiple cell contents.

Again, my code works for all things input... however, when I highlight multiple cells and clear their contents, I receive the Run Time Error.

My Code:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim RequiredE As String
Dim RequiredH As String <-- Ignore this for this post, I have the same block of code below running against additional columns
Dim RequiredK As String <-- <-- Ignore this for this post, I have the same block of code below running against additional columns

If Target.Column = Columns("D").Column Then

Do
If Target.Value = "Yes" Then <-- Run Time Error debugger points me here
RequiredE = InputBox("Please enter IT User's name, who's responsible for sign off to PLIT Release Coordinator and click OK", "IT user name required!", Range("E" & Target.Row).Text)
Else
RequiredE = "Not Applicable"
End If

Range("E" & Target.Row) = RequiredE

Loop Until RequiredE <> ""

End If
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
If you select and change multiple cells, Target.Column (for instance) will throw an error as the .Column will not work on an area with multiple cells.

You need to test if the Target has multiple cells or not.

If Target.Columns.Count > 1 Then ...
 
Upvote 0
Thank you Wigi for your reply and suggestion, I put that in my code and as much as I don't get the Run Time Error 13 anymore, none of my other logic is working... Which I definitely need to it to work.

I think this may show the flow better:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim RequiredE As String
Dim RequiredH As String <-- This can be ignored, it's for another block of code
Dim RequiredK As String <-- This can be ignored, it's for another block of code

     If Target.Column = Columns("D").Column Then
         
         Do
             If Target.Value = "Yes" Then <-- When I get the run time error after highlighting multiple cells and clearing their content, this is where debug takes me
                 RequiredE = InputBox("Please enter IT User's name, who's responsible for sign off to PLIT Release Coordinator and click OK", "IT user name required!", Range("E" & Target.Row).Text)
             Else
                 RequiredE = "Not Applicable"
             End If
     
             Range("E" & Target.Row) = RequiredE
    
         Loop Until RequiredE <> ""
        
     End If
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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