filtered range to 2-Day array

ericlch16

Active Member
Joined
Nov 2, 2007
Messages
311
Office Version
  1. 2016
  2. 2013
Platform
  1. Windows
I have a range that has a couple of filters.

Set rng = .Range(.Cells(startrowsort, 1), .Cells(lastemptyrowsort, 15))
TempArray() = rng

However I wanted that array to contain only VISIBLE data. Right now it includes everything data(visible and not visible). Is there a quick way to get only visible data to an array without LOOPING ?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Set rng = .Range(.Cells(startrowsort, 1), .Cells(lastemptyrowsort, 15)).SpecialCells(xlCellTypeVisible)

will include only visible cells, but if those cells are not all contiguous you would have to loop through each area of rng and create an array for each area.
Here's an example of a range (R) that has three areas with values for each in the array Varr().
VBA Code:
Sub test()
'Create a non-contiguous range that has 3 areas (one cell in each area)
Dim R As Range, Varr
Set R = Range("B2,C6,E9")
ReDim Varr(1 To R.Areas.Count)
For i = 1 To R.Areas.Count
    MsgBox R.Areas(i).Address
    Varr(i) = R.Areas(i).Value
    MsgBox Varr(i)
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,684
Members
448,977
Latest member
dbonilla0331

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top