Hi,
I have a code that looks at text in a range in column B and then counts how many times this text is found in column D (see code below)
I have found that if a text in column B is more than 255 letters (so 256 letters or more) then the code does not work and gives and gives a Run-time error '13': Type mismatch.
Does anybody know how I can fix the code so that it also counts text with more then 255 letters and I no longer get the type mismatch error?
Thanks,
Nic
I have a code that looks at text in a range in column B and then counts how many times this text is found in column D (see code below)
VBA Code:
Sub FindTotal()
Application.ScreenUpdating = False
Dim rng As Range, total As Long
For Each rng In Range("B4", Range("B" & Rows.Count).End(xlUp))
total = total + WorksheetFunction.CountIf(Range("D4", Range("D" & Rows.Count).End(xlUp)), rng)
Next rng
MsgBox total
Application.ScreenUpdating = True
End Sub
I have found that if a text in column B is more than 255 letters (so 256 letters or more) then the code does not work and gives and gives a Run-time error '13': Type mismatch.
Does anybody know how I can fix the code so that it also counts text with more then 255 letters and I no longer get the type mismatch error?
Thanks,
Nic