View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mike Williams[_3_] Mike Williams[_3_] is offline
external usenet poster
 
Posts: 3
Default Selecting a Range after Autofilter

Hello,

I'm very very new to Excel VBA programming and I have a question in
regards to selecting Ranges after an Autofilter has been applied.

The user will filter the sheet down to their criteria and then I need
to loop through columns A and B and add the filtered data to an array.

Here the code I have so far:

Dim LastRow
Dim b()

Range("A65536").End(xlUp).Select
LastRow = ActiveCell.Row

b = Range("A2:B2" & LastRow).SpecialCells(xlCellTypeVisible).value

The problem is that it's not selecting all the values. I'm assuming a
thick gray line between row numbers in an autofilter indicates a
separate range. It only pulls the data from the "first" range. How do I
select all the ranges into one? and assign it to b?