Hi All,
I currently have a formula, which i would like to perform via vba instead.
the formula is as follows:
=VLOOKUP(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C3,"~","~~"),"?","~?"),"*","~*"),
'OPID Report'!$A1:$B25000,2,FALSE)
I have been trying to do this for a while now, but with no joy.
The way i had considered doing this was, using if statements which would look something like this:
Obviously the above doesn't work, but hopefully it will give you the principle of what i want to do. Basically, if the first substitute criteria is met, it should perform the substitute function and then go to the vlookup, if it isn't met it should move onto the second one. It should loop through each criteria on this basis, and if none of the substitute criteria are met then it should just perform the vlookup.
Is anybody able to help me out with this?
Thanks,
I currently have a formula, which i would like to perform via vba instead.
the formula is as follows:
=VLOOKUP(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C3,"~","~~"),"?","~?"),"*","~*"),
'OPID Report'!$A1:$B25000,2,FALSE)
I have been trying to do this for a while now, but with no joy.
The way i had considered doing this was, using if statements which would look something like this:
Code:
If Application.WorksheetFunction.Left(rngRequested) = "*" Then
rngRequested = Application.WorksheetFunction.Substitute(rngRequested, "*", "~*")
End If
If Application.WorksheetFunction.Left(rngRequested) = "?" Then
rngRequested = Application.WorksheetFunction.Substitute(rngRequested, "?", "~?")
End If
If Application.WorksheetFunction.Left(rngRequested) = "~" Then
rngRequested = Application.WorksheetFunction.Substitute(rngRequested, "~", "~~")
End If
employee = Application.WorksheetFunction.VLookup(rngRequested, OpidReport, 2, False) 'Name
If Err <> 0 Then
ActiveCell.Offset(0, 1).Value = "User Not Found"
Else
Operator = employee
ActiveCell.Offset(0, 1).Value = Operator
Obviously the above doesn't work, but hopefully it will give you the principle of what i want to do. Basically, if the first substitute criteria is met, it should perform the substitute function and then go to the vlookup, if it isn't met it should move onto the second one. It should loop through each criteria on this basis, and if none of the substitute criteria are met then it should just perform the vlookup.
Is anybody able to help me out with this?
Thanks,