I create a new module and insert this code:
Sub test()
Set wsData = ThisWorkbook.Worksheets("Data")
sCount = wsData.Columns(14).SpecialCells(xlCellTypeBlanks).Count
msgbox sCount
End Sub
In the worksheet "Data", I have this code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Selection.CountLarge = 1 Then
If Not Intersect(Target, Range("K:M")) Is Nothing And Target.Value <> "" Then
'code
End if
End if
End Sub
When I run the test() sub, I get a type mismatch error on If Not Intersect(Target, Range("K:M")) Is Nothing, as Target wrong type.
Why this is happening?
Why is test triggering the Change Event? I dont get the same error if manually filter column 14 of my Data sheet to leave only the blank cells!
Worksheets("Data").Range("K:M")instead ofRange("K:M")? - Mistellatesttriggering theChangeEvent? - TomwbTis not defined intest()? - Dan.SpecialCells(xlCellTypeBlanks)maybe triggers a filter on the sheet... do you get the same error if you manually filter column 14 of your Data sheet to leave only the blank cells? - Dan.SpecialCells(xlCellTypeBlanks)does trigger theselectionChangeevent. The selection is the blank cells. I knew it just 30 sec before :P - newacc2240