Match function and displaying results

G

Guest

I have the following modified code (provided by Tom Ogilvy and Bob Phillips):

Dim rng as Range, rng1 as Range
dim res as Variant
SetRng = VMM_Workbook.Worksheets(ShortVMM_FileName).Range("D1:D2000")
res = Application.Match(Range(ID_Location), VMM_Sig_Name_Rng.Offset(0, -2), 0)
if iserror(res) then
msgbox "Not found"
else
set rng1 = rng(res)
msgbox rng1.Value & " Address: " & rng1.Address
End if

Offset(1, 15).Value = rng1 ????

I want to have two actions happen:
1. If there is an error I want to assign "SIGNAL ID NOT DEFINED" to the rng1.
2. Error or not, I want to insert the results into a relative address, which
depends on the present location.

Thanks
 
G

Guest

If there is an error there is no rng1 - and you can't assign a string value
to it.

if iserror(res) then
Activecell.offset(1,15).Value = "SIGNAL ID NOT DEFINED"
else
ActiveCell.offset(1,15).Value = _
VMM_Sig_Name_Rng.Offset(res, -2).Resize(1,1).Value
End sub
 
G

Guest

Why does
set rng1 = rng(res) return the first value in the range and
ActiveCell.offset(1,15).Value = _
VMM_Sig_Name_Rng.Offset(res, -2).Resize(1,1).Value return the second?

How do I get the first?

Also please explain the resize function? Will this allow me to extract
multiple (rows/columns) from the range? i.e. return the first 5 rows and 3
columns?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Move up text 2
Product not found error 6
compare all matches 3
Linking workbooks 2
Recognise value not formula 4
Clear then move text up 9
delete row 2
Help with code 7

Top