I have 8 columns that i am iterating through with a for loop. I excuted my code for only one column and used this to get the range of one column Worksheets("x").Range("H:H")
. The code executes fine.
Set study_visit_rng = Worksheets("wksht").Range("H:H") - this will work fine
however, when I use the .Columns
object to iterate it throws a type mismatch when i am searching that column
For v = 8 To 18
Dim study_visit_rng As Range
Set study_visit_rng = Worksheets("wksht").Columns(v) 'using the columns object
'iterating through the columns
For Each cell In study_visit_rng
If Trim(cell.Value) = "RES" Or Trim(cell.Value) = "SOC" Then '~ I get the type mismatch here
If InStr(Range("C" & (cell.Row)).Value, "History") Then
'i do something
End If
End If
Next cell