Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 441
Default Use FIND to return an array of items

Thanks much to all who replied. I found all responses helpful.

"Jim Thomlinson" wrote:

I like Tom's idea better than the range of addresses. That being said here is
the code for the range of addresses. I would be pretty easy to modify this to
use the union method.

Const STRING_TO_FIND As String = "This"

Sub MakeArray()
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFirstOccurence As Range
Dim aryAddresses() As String
Dim lngCounter As Long

lngCounter = 0
Set wks = ActiveSheet
Set rngToSearch = wks.Range("A1:A100")
Set rngFound = rngToSearch.Find(STRING_TO_FIND)

If Not rngFound Is Nothing Then
Set rngFirstOccurence = rngFound
Do
ReDim Preserve aryAddresses(lngCounter)
aryAddresses(lngCounter) = rngFound.Address
Set rngFound = rngToSearch.FindNext(rngFound)
lngCounter = lngCounter + 1
Loop Until rngFound.Address = rngFirstOccurence.Address
End If

End Sub

HTH

"quartz" wrote:

I am using Excel 2003 with Windows XP.

I need to be able to return an array of the cell addresses of all
occurrences of a certain value in a sheet, preferably using the FIND command.
Anyone have a clue as to how to do this? If so, could you please post an
example function or code?

Thanks much in advance.

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
Find a value in an array and return cell address PJFry Excel Worksheet Functions 12 January 28th 09 02:23 PM
Find Max in array- return corresponding cell [email protected] Excel Worksheet Functions 1 August 22nd 07 03:59 AM
Array Formula to find Average Return Paul987 Excel Discussion (Misc queries) 1 May 9th 06 06:20 PM
Find values in table and return correpsonding data in array Ryan Excel Programming 1 April 14th 04 07:19 AM
VBA Syntax for VLOOKUP to return array of return values Alan Beban[_3_] Excel Programming 7 August 5th 03 11:41 AM


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

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"