Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Fastest find method for number interval

Hi Reinhard,

The following code will create an array from the visible data. I have
provided several options of code that are commented out for what can be
placed in the array.

Is this what you are looking for? You can have a 2 dimensional array by
using offset to get the adjacent cells to c. Like c.Offset(0,1) will be the
adjacent cell.

Sub AutofilterArray()
Dim MyArray()
Dim lngElements As Long
Dim i As Long
Dim rngVisible As Range
Dim c As Range

'Test that Autofilter is turned on
If Sheets("Sheet1").AutoFilterMode Then
If Sheets("Sheet1").FilterMode Then
Sheets("Sheet1").ShowAllData
End If

With Sheets("Sheet1").AutoFilter.Range
.AutoFilter Field:=1, Criteria1:="=3", _
Operator:=xlAnd, Criteria2:="<4"

Set rngVisible = .Columns(1).Offset(1) _
.Resize(.Rows.Count - 1) _
.SpecialCells(xlCellTypeVisible)

lngElements = rngVisible.Cells.Count

ReDim MyArray(lngElements)
i = 0
For Each c In rngVisible
'Place value of cell in array
MyArray(i) = c.Value

'Place relative address in array
'MyArray(i) = c.Address(0, 0)

'Place Absolute address in array
'MyArray(i) = c.Address(1, 1)

'Place row number in array
'MyArray(i) = c.Row

i = i + 1
Next c
End With

'For testing only.
'left here in case you want it
For i = 0 To UBound(MyArray) - 1
MsgBox MyArray(i)
Next i

Else
MsgBox "AutoFilter is not turned on" & _
vbCrLf & "Processing terminated"
End If

'Following displays the range array
'MsgBox rngVisible.Address

End Sub

--
Regards,

OssieMac


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Fastest find method for number interval

Interesting suggestion. I'll give it a try.
Thanks
Reinhard

"OssieMac" schrieb im Newsbeitrag
...
Hi Reinhard,

The following code will create an array from the visible data. I have
provided several options of code that are commented out for what can be
placed in the array.

Is this what you are looking for? You can have a 2 dimensional array by
using offset to get the adjacent cells to c. Like c.Offset(0,1) will be
the
adjacent cell.

Sub AutofilterArray()
Dim MyArray()
Dim lngElements As Long
Dim i As Long
Dim rngVisible As Range
Dim c As Range

'Test that Autofilter is turned on
If Sheets("Sheet1").AutoFilterMode Then
If Sheets("Sheet1").FilterMode Then
Sheets("Sheet1").ShowAllData
End If

With Sheets("Sheet1").AutoFilter.Range
.AutoFilter Field:=1, Criteria1:="=3", _
Operator:=xlAnd, Criteria2:="<4"

Set rngVisible = .Columns(1).Offset(1) _
.Resize(.Rows.Count - 1) _
.SpecialCells(xlCellTypeVisible)

lngElements = rngVisible.Cells.Count

ReDim MyArray(lngElements)
i = 0
For Each c In rngVisible
'Place value of cell in array
MyArray(i) = c.Value

'Place relative address in array
'MyArray(i) = c.Address(0, 0)

'Place Absolute address in array
'MyArray(i) = c.Address(1, 1)

'Place row number in array
'MyArray(i) = c.Row

i = i + 1
Next c
End With

'For testing only.
'left here in case you want it
For i = 0 To UBound(MyArray) - 1
MsgBox MyArray(i)
Next i

Else
MsgBox "AutoFilter is not turned on" & _
vbCrLf & "Processing terminated"
End If

'Following displays the range array
'MsgBox rngVisible.Address

End Sub

--
Regards,

OssieMac



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 number of particular values over an interval CarterTC Excel Discussion (Misc queries) 3 February 7th 12 08:44 PM
Fastest find method for number interval Driftwood Excel Programming 1 May 19th 09 10:11 AM
How to find maximum non-blank row number without brute force method? Chet Excel Programming 2 April 4th 08 08:28 AM
Bulk Row Deletion - Fastest method quartz[_2_] Excel Programming 11 November 11th 04 12:07 PM
Find fastest way to do lookups Fred Smith Excel Programming 7 April 18th 04 07:44 AM


All times are GMT +1. The time now is 10:45 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"