type mismatch??

daveyc18

Active Member
Joined
Feb 11, 2013
Messages
473
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
 

Some videos you may like

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,594
Office Version
  1. 2007
Platform
  1. Windows
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
 

daveyc18

Active Member
Joined
Feb 11, 2013
Messages
473
Office Version
  1. 365
  2. 2010
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 ....
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,594
Office Version
  1. 2007
Platform
  1. Windows
Re: type mistmatch??

I think the counting function does not check exactly on the filtered rows.
 

daveyc18

Active Member
Joined
Feb 11, 2013
Messages
473
Office Version
  1. 365
  2. 2010

ADVERTISEMENT

Re: type mistmatch??

I think the counting function does not check exactly on the filtered rows.

I see..
it's so odd...only happens when the filter returns two rows of data ...
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,594
Office Version
  1. 2007
Platform
  1. Windows
Re: type mistmatch??

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

Watch MrExcel Video

Forum statistics

Threads
1,122,165
Messages
5,594,622
Members
413,918
Latest member
Mikey_C

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
Top