Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default VBA Test on Array - Find a value

Hi Experts

A question - I want to search an array called lastknowngood to find out if a
value exits within it. The arary is a Variant data type but try as I may I
cannot find out how to do this easily. If you help many thanks in advance.

Sheets("Master").Select
lastknowngood = Range("j11:j75").Value
sFile = Dir(sPath & sExtension)

so I want to test if the sFile variable exists in the lastknowngood array at
any point?

regards and hoping someone has a quick fix or idea

--
C Ward
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default VBA Test on Array - Find a value

Dim varRange As Range

Set varRange = Sheets("Master").Range("J11:J75")
Set varFound = varRange.Find(lastknowngood)
If Not varFound Is Nothing Then
'Found
sFile = Dir(sPath & sExtension)
End If

If this post helps click Yes
---------------
Jacob Skaria


"christopher ward" wrote:

Hi Experts

A question - I want to search an array called lastknowngood to find out if a
value exits within it. The arary is a Variant data type but try as I may I
cannot find out how to do this easily. If you help many thanks in advance.

Sheets("Master").Select
lastknowngood = Range("j11:j75").Value
sFile = Dir(sPath & sExtension)

so I want to test if the sFile variable exists in the lastknowngood array at
any point?

regards and hoping someone has a quick fix or idea

--
C Ward

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default VBA Test on Array - Find a value

I hope the variable to be searched is sFile. In which case you need to find
for sFile...

Dim varRange As Range
Dim varFound As Variant

sFile = "<search string"

Set varRange = Sheets("Master").Range("J11:J75")
Set varFound = varRange.Find(sFile)
If Not varFound Is Nothing Then
Msgbox sFile & "is in range"
Else
Msgbox sFile & "not in range"
End If

--
If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Dim varRange As Range

Set varRange = Sheets("Master").Range("J11:J75")
Set varFound = varRange.Find(lastknowngood)
If Not varFound Is Nothing Then
'Found
sFile = Dir(sPath & sExtension)
End If

If this post helps click Yes
---------------
Jacob Skaria


"christopher ward" wrote:

Hi Experts

A question - I want to search an array called lastknowngood to find out if a
value exits within it. The arary is a Variant data type but try as I may I
cannot find out how to do this easily. If you help many thanks in advance.

Sheets("Master").Select
lastknowngood = Range("j11:j75").Value
sFile = Dir(sPath & sExtension)

so I want to test if the sFile variable exists in the lastknowngood array at
any point?

regards and hoping someone has a quick fix or idea

--
C Ward

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default VBA Test on Array - Find a value

Thanks Jacob - worked a treat
--
C Ward


"Jacob Skaria" wrote:

Dim varRange As Range

Set varRange = Sheets("Master").Range("J11:J75")
Set varFound = varRange.Find(lastknowngood)
If Not varFound Is Nothing Then
'Found
sFile = Dir(sPath & sExtension)
End If

If this post helps click Yes
---------------
Jacob Skaria


"christopher ward" wrote:

Hi Experts

A question - I want to search an array called lastknowngood to find out if a
value exits within it. The arary is a Variant data type but try as I may I
cannot find out how to do this easily. If you help many thanks in advance.

Sheets("Master").Select
lastknowngood = Range("j11:j75").Value
sFile = Dir(sPath & sExtension)

so I want to test if the sFile variable exists in the lastknowngood array at
any point?

regards and hoping someone has a quick fix or idea

--
C Ward

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
Test if a variable is given as array? Charlotte E Excel Programming 12 April 19th 09 02:42 PM
Test if cell value is in an array Rita Brasher Excel Programming 1 March 30th 09 08:47 PM
Test Initialization of an Array Neal Zimm Excel Programming 7 December 27th 06 04:58 PM
Array Test VBA Dabbler[_2_] Excel Programming 9 March 30th 05 09:53 PM
Test for end of array of objects? peter Excel Programming 8 February 3rd 05 09:15 AM


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

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"