LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default InList()?

I've hacked merrily along with this, but following values in Watch, it
appears I have failed to understand it correctly. Here's what I have:

v = Array("PEN-Pensionalble Earnings", _
"PN2-Pension Plan Charlotte Hly HN2", _
"TSP-Textron Savings Plan")
res = Application.Match(rngCell.Value, v, 0)

and when rngCell.Value = "PEN-Pensionalble Earnings", it is returning an
error. I also tried it just using the form in your example of

res = Application.Match(rng, v, 0)

and got the same result.

Where did I go wrong, mother darling?
--
Dave
Temping with Staffmark
in Rock Hill, SC


"Tom Ogilvy" wrote:

No Inlist or equivalent command. One way:

Dim v as Variant, res as Variant
v = Array("PEN-Pensionalble Earnings", _
"PN2-Pension Plan Charlotte Hly HN2", _
"TSP-Textron Savings Plan")
res = Application.Match(rng,v,0)
if not iserror(res) then
' matches item in the list

end if

You can add to the list. If res isn't an error value, then you can use
v(res)
to tell you which it matched.


--
Regards,
Tom Ogilvy


"Dave Birley" wrote:

In VFP there is a Function called InList() where you may build an If-EndIf
expression around a list of candidates.

At the moment, in a Macro, I have this:

If rngCell.Value = "PEN-Pensionable Earnings" Or _
rngCell.Value = "PN2-Pension Plan Charlotte Hly HN2" Or _
rngCell.Value = "TSP-Textron Savings Plan" Then

However, on examining my data I discover that there are perhaps another
DOZEN possible candidates. Do I have to continue building that horrendous Or
expression, or can I pack all these pups into a Variable and apply my If End
If expression to just the variable?
--
Dave
Temping with Staffmark
in Rock Hill, SC

 
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



All times are GMT +1. The time now is 05:19 PM.

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

About Us

"It's about Microsoft Excel"