type mismatch??

daveyc18

Active Member
Joined
Feb 11, 2013
Messages
388
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,920
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
388
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,920
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
388
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,920
Office Version
2007
Platform
Windows
Re: type mistmatch??

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

Forum statistics

Threads
1,078,461
Messages
5,340,440
Members
399,375
Latest member
alwayssunny

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top