View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_5_] Dave Peterson[_5_] is offline
external usenet poster
 
Posts: 1,758
Default using worksheet functions INDEX and MATCH within a macro

dim res as variant
dim myVal as variant

res = application.match(cboProductSelect.Value, _
worksheets("sheet1").range("a1:a999"), 0)

if iserror(res) then
msgbox "No match found"
else
myval = worksheets("sheet1").range("b1:b999")(res)
end if

I wasn't sure what range1 and range2 were.



JurgenBrea wrote:

I would like to use a worksheet function in a macro. This is how I would do
it if I were entering it straight into a cell:

=INDEX(range1,MATCH(F1,range2,0))

Can anyone tell me how I would enter it into the macro?

The F1 would change to "cboProductSelect.Value", but other than that it
should be simple, right? *hopeful*

I found this reference, but haven't managed to get it working by trying to
follow the guidelines as my formula has too many differences:
http://msdn.microsoft.com/library/de...HV05205786.asp


--

Dave Peterson