Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Match function and displaying results

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Match function and displaying results

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

--
Regards,
Tom Ogilvy


"Dan" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Match function and displaying results

Thanks for the response. It's what I thought but hoped someone had some tricks.

"Tom Ogilvy" wrote:

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

--
Regards,
Tom Ogilvy


"Dan" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Match function and displaying results

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

"Tom Ogilvy" wrote:

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

--
Regards,
Tom Ogilvy


"Dan" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrong results from MATCH function Imladrian Excel Worksheet Functions 4 April 25th 23 09:02 AM
eval of concatenate function not displaying results tony12345 Excel Discussion (Misc queries) 1 March 6th 09 05:25 PM
Displaying how many results in a vlookup Danhalawi Excel Discussion (Misc queries) 1 November 16th 06 10:47 AM
functions are not displaying the results [email protected] Excel Worksheet Functions 1 February 16th 06 01:27 PM
Sorting and displaying different results Mac New Users to Excel 1 April 6th 05 03:10 AM


All times are GMT +1. The time now is 02:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"