Type Mismatch error

docam84

New Member
Joined
May 29, 2007
Messages
23
Hello,

I am having trouble trying to prevent this error from popping up and I was wondering if anyone could give me any clue as to why this is occurring.

My code checks to see if a cell contains a certain status, such as Approved or Rejected. If the status is Approved, then the procedure copies the row and pastes it onto a different worksheet within the same workbook. The row is then deleted (in the ChangeStatus procedure).

Here is my code:

<code>
Dim strClient As String

<font color = "blue">On Error GoTo ErrHandler</font>

<font color = "blue">If Not Intersect</font>(Target, Range("L2:L500")) Is Nothing Then

     strClient = Target.Offset(0, -10).Value

     Call ChangeStatus(Target.Row, Target.Value)

End If

Exit Sub

ErrHandler:

' // statements for error handler

Exit Sub
</code>
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
maybe instead of .Value you can use .Text or .ToString because strClient should come up as a string, not a numerical value..
 
Upvote 0
Does Target consist of more than one cell?
Regards,
Rory
 
Upvote 0
Initially, no, but I think that Excel is getting choked up when I delete the entire row, because it's triggering the worksheet change event.
 
Upvote 0
Where/when do you get the error?

What are you actually doing with strClient?
 
Upvote 0
You might try disabling events before the deletion and then re-enabling them:
Code:
Application.EnableEvents = False
' do your thing
Application.EnableEvents = True
 
Upvote 0
I get the error when the row is deleted. strClient is passed by reference to a procedure that determines which type of client it is.
 
Upvote 0
And where do you get the error?

Because I don't see any code passing that variable to another routine.:eek:

By the way I think rorya could be on the right track.:)
 
Upvote 0
Norie,

You were right about rorya's suggestion. It did work and I didn't get any errors :) although I was using the errorhandler to subdue the error, but it was annoying nonetheless.

Thanks!!
 
Upvote 0

Forum statistics

Threads
1,215,539
Messages
6,125,403
Members
449,222
Latest member
taner zz

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