То, что я пытаюсь сделать, это добавить переменную как часть условия функции countif, но она не работает. Должен ли я использовать функцию «Счет» или «Формула счет»?
Параметр Явный
Sub tes ()
Dim ws3 As Worksheet, ws4 As Worksheet
Dim i As Long
Dim rngSearch As Range, rngFound As Range
Dim arr As Variant
Dim strValueC As String, strValueF As String
With ThisWorkbook
Set ws3 = .Worksheets("3 unprotected")
Set ws4 = .Worksheets("DATA")
End With
With ws3
arr = Range("A6:A33")
Range("B6:C33").Clear
End With
Set rngSearch = ws4.Range("B1:B5049")
For i = LBound(arr) To UBound(arr)
Set rngFound = rngSearch.Find(What:=arr(i, 1), LookIn:=xlValues, LookAt:=xlWhole)
If Not rngFound Is Nothing Then
With ws4
strValueC = .Range("C" & rngFound.Row).Value
strValueF = .Range("F" & rngFound.Row).Value
End With
With ws3
.Range("B" & i + 5).Value = strValueC
.Range("C" & i + 5).Value = strValueF
.Range("D" & i + 5).Value = WorksheetFunction.CountIf(Range("DATA!B:B", "A" & i + 5)) 'Error here, compile error. Argument not optial
End With
End If
Next i
End Sub