type mismatch??

daveyc18

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

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
7,721
Office Version
2007
Platform
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
387
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
7,721
Office Version
2007
Platform
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
387
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
7,721
Office Version
2007
Platform
Windows
Re: type mistmatch??

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

Forum statistics

Threads
1,077,797
Messages
5,336,385
Members
399,079
Latest member
DeoW

Some videos you may like

This Week's Hot Topics

Top