PDA

View Full Version : Help VBA using excel function help



dankot123
01-15-2017, 01:25 PM
object_loc = Application.WorksheetFunction.Match(object, data.range("B1: B100"), 0)

when i use a value for object that isn't in the list the entire function doesn't run, is there a way to say if there is no value like object in the list to skip this step

maybe

if object_loc (does not exist) then

"Do this"

else

" use object_loc"

end if

or is there another way

anthony47
01-15-2017, 01:53 PM
I use this syntax:


object_loc = Application.Match(object, data.range("B1: B100"), 0)
If Not IsError(object_loc) Then
' what to do if Value was found
Else
' what to do if value is not found
End If


object_loc has to be dimensioned as a Variant, if you "dim" it:

Dim object_loc as Variant

Bye

dankot123
01-15-2017, 04:46 PM
I use this syntax:


object_loc = Application.Match(object, data.range("B1: B100"), 0)
If Not IsError(object_loc) Then
' what to do if Value was found
Else
' what to do if value is not found
End If


object_loc has to be dimensioned as a Variant, if you "dim" it:

Dim object_loc as Variant

Bye
Thank you soo much