ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Checking list for contents (https://www.excelbanter.com/excel-programming/372899-checking-list-contents.html)

Odido

Checking list for contents
 
Hi,

I want to read a list of string-values out of cells (e.g. H2:H8) in
Excel into a variable (array) of excel-vba. Is there another
possibility to achieve this than reading one value after the other?

Then I want to check with a single code-line if a value is part of the
array and continue execution depending on the result:

if var_test "is part of" var_array then ......

Can anybody tell me how to do this?

Thx for your help
Oliver


Die_Another_Day

Checking list for contents
 
Oliver, try dimming a range, then use .Find
Dim r As Range
Dim fRange As Range
Set r = Range("H2:H8")
Set fRange = r.Find(What:="YourText") 'Add other parameters as
neccessary
If fRange Is Nothing Then 'Not Found

if that doesn't work for you try searching for "Scripting.Dictionary"
or check out this post:
http://groups.google.com/group/micro...67bb607702 9e

Charles Chickering

Odido wrote:
Hi,

I want to read a list of string-values out of cells (e.g. H2:H8) in
Excel into a variable (array) of excel-vba. Is there another
possibility to achieve this than reading one value after the other?

Then I want to check with a single code-line if a value is part of the
array and continue execution depending on the result:

if var_test "is part of" var_array then ......

Can anybody tell me how to do this?

Thx for your help
Oliver



Odido

Checking list for contents
 
Charles,

wow, thats great - thank you very much. That seems to be exactly what I
was looking for.

Have a nice day
Oliver



All times are GMT +1. The time now is 11:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com