I want to do a vlookup and after finding a value (which will be 1 or 0), I want to put a condition: if it is 1, divide some values of the worksheet by 100.
When executing this code, the error '1004' appears: Unable to get the Vlookup property of the worksheetfunction class
Sub test()
Dim inp As Workbook
Set inp = Workbooks("input_dados.xlsm")
For i = 2 To 3
For x = 2 To 112
Dim NewRange As Range
Set NewRange = inp.Sheets("Flag_divide").Range(inp.Sheets("Flag_divide").Cells(3, 2), inp.Sheets("Flag_divide").Cells(112, 3))
Dim var_macro As String
var_macro = inp.Sheets("input").Cells(x + 1, 2).Value
Dim marks As Integer
marks = Application.WorksheetFunction.VLookup(var_macro, NewRange, 2, False)
If marks = 1 Then
inp.Sheets("input").Cells(x + 1, i + 1).Value = (inp.Sheets("input").Cells(x + 1, i + 1).Value) / 100
End If
Next x
Next i
End Sub