type mismatch??

daveyc18

Well-known Member
Joined
Feb 11, 2013
Messages
707
Office Version
  1. 365
  2. 2010
if i have this

Code:
finalrow = Cells(Rows.Count, "A").End(xlUp).Row

Set myrange = range("c3:c" & finalrow).SpecialCells(xlVisible)

     If Application.CountIf(myrange, "Repo") =  0 Then

im basically filtering, one at a time, each name in column A and looking if there are repos in column C...if there's not, do some code ...otherwise, do some other code


but for whatever reason....i got this type mismatch error for one specific name....when i filter for that name....one row has repo, the other row has reverse in column C


the code works just fine for other names where there are both "repo" and "reverse"

i guess the thing that stands about this particular name is that there are only two rows of data, whereas the other names with repo and reverse had several rows of data for each
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Re: type mistmatch??

To count filtered values, try this


Code:
  Dim fRow As Long, myAdrs As String, c As Variant
  fRow = Cells(Rows.Count, "A").End(xlUp).Row
  myAdrs = Range("C3:C" & fRow).Address
  c = Evaluate(Replace("SUMPRODUCT(SUBTOTAL(103,OFFSET($C$3,ROW(#)-ROW($C$3),,1))*(#=""Repo""))", "#", myAdrs))
  If c = 0 Then
 
Upvote 0
Re: type mistmatch??

To count filtered values, try this


Code:
  Dim fRow As Long, myAdrs As String, c As Variant
  fRow = Cells(Rows.Count, "A").End(xlUp).Row
  myAdrs = Range("C3:C" & fRow).Address
  c = Evaluate(Replace("SUMPRODUCT(SUBTOTAL(103,OFFSET($C$3,ROW(#)-ROW($C$3),,1))*(#=""Repo""))", "#", myAdrs))
  If c = 0 Then

thanks ...I'll try when I go back to work tmr

what do u think is triggering the error though ? so lost ....
 
Upvote 0
Re: type mistmatch??

I think the counting function does not check exactly on the filtered rows.
 
Upvote 0
Re: type mistmatch??

I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,561
Messages
6,114,317
Members
448,564
Latest member
ED38

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