worksheetfunction.match
If you use .worksheetfunction, and there is no match, you'll get a runtime
error.
I use this instead:
Dim R as variant 'could be an error
Dim Trange as range
Set Trange=sheets("drawing").range("G2:G235")
R=application.match( 19031,Trange,0)
if iserror(r) then
msgbox "not found"
else
Msgbox R
end if
=========
You could also check for the runtime error:
Dim R as long
Dim Trange as range
Set Trange=sheets("drawing").range("G2:G235")
on error resume next
R=application.worksheetfunction.match( 19031,Trange,0)
if err.number < 0 then
msgbox "Not found"
err.clear
else
Msgbox R
end if
on error goto 0
Li Jianyong wrote:
I am trying to use worksheetfunction.match to get the data postion in a
range named sheets("drawing").range("G2:G235")
the code is
Dim R as long
Dim Trange as range
Set Trange=sheets("drawing").range("G2:G235")
R=application.worksheetfunction.match( 19031,Trange,0)
Msgbox R
....
I am sure the no. 19031 mentioned above are in the range. But when I run
this program, it appears err.number 1004. I can not get the R value
please provide help. thanks
Li Jianyong
--
Dave Peterson
|