473,433 Members | 2,086 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,433 software developers and data experts.

How do I get filter values in vba?

Hello all,
I am using Excel 2002.
I have a list of data in coloumn A.
I have applied autofilter on that list
and now I am interested in getting the values
that appear when clicking the filter arrow, in vba.

Can anyone help me?

Thanks in advance.

v
Apr 18 '07 #1
3 26583
SammyB
807 Expert 512MB
Hello all,
I am using Excel 2002.
I have a list of data in coloumn A.
I have applied autofilter on that list
and now I am interested in getting the values
that appear when clicking the filter arrow, in vba.

Can anyone help me?

Thanks in advance.

v
To get all of the current Autofilter:
Cells(1, 1).CurrentRegion.SpecialCells(xlCellTypeVisible)

To get just the values in column A:
Range(Cells(2, 1), Cells(2, 1).End(xlDown)).SpecialCells(xlCellTypeVisible)

So, for example
Expand|Select|Wrap|Line Numbers
  1.     Dim c As Range
  2.     For Each c In Range(Cells(2, 1), Cells(2, 1).End( xlDown )).SpecialCells(xlCellTypeVisible).Cells
  3.         MsgBox c.Value
  4.     Next c
HTH --Sam
Apr 18 '07 #2
To get all of the current Autofilter:
Cells(1, 1).CurrentRegion.SpecialCells(xlCellTypeVisible)

To get just the values in column A:
Range(Cells(2, 1), Cells(2, 1).End(xlDown)).SpecialCells(xlCellTypeVisible)

So, for example
Expand|Select|Wrap|Line Numbers
  1.     Dim c As Range
  2.     For Each c In Range(Cells(2, 1), Cells(2, 1).End( xlDown )).SpecialCells(xlCellTypeVisible).Cells
  3.         MsgBox c.Value
  4.     Next c
HTH --Sam


Hello Sam,
First, thank you for your reply.

I tried the code you sent and it turns out that it produces all of the
values in the column A.
What I need is the list of values without repeating themselves.
I hope it is clear.

thanks
v
Apr 19 '07 #3
SammyB
807 Expert 512MB
> it produces all of the values in the column A.

Not if the auto-filter is on and there is a blank cell at the end of the filtered data. See http://www.thescripts.com/forum/thread634286.html for more help. If you record a macro, turning on the AutoFilter & doing the manual steps in that post, you can see what code you are missing. HTH --Sam
Apr 19 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Robin Cull | last post by:
Imagine I have a dict looking something like this: myDict = {"key 1": , "key 2": , "key 3": , "key 4": } That is, a set of keys which have a variable length list of associated values after...
1
by: Robert Neville | last post by:
I would like to add filter functionality to my database whether through the Main form or the subform. This question may be rudimentary, yet I have not less experience with filtering data outside...
16
by: Preben Randhol | last post by:
Hi A short newbie question. I would like to extract some values from a given text file directly into python variables. Can this be done simply by either standard library or other libraries? Some...
23
blyxx86
by: blyxx86 | last post by:
I am trying to filter multiple entries with only one search box. That way the user can type whatever they want and find all the values that contain what they enter. Private Sub...
3
by: NewtoAccess | last post by:
Access 2000, regarding forms. I want a command BUTTON labeled "server" on a MAINFORM that: > Opens up a INVENTORY form-which contains a list box- and > Filter the values in the LIST BOX (for...
1
by: The.Daryl.Lu | last post by:
Hi, two parts to my problem if someone can help address either one or both: 1. I want to SELECT everything in the table if it matches the criteria when the query button is pressed (this is just...
7
nev
by: nev | last post by:
i declared 2 datatables: dim dtt1 as datatable = ds.datatable1 dim dtt2 as datatable = ds.datatable2 dtt1 has firstname, lastname columns dtt2 has firstname column when i filter dtt1 by...
9
by: kwerkyone | last post by:
I have two separate but similar databases and each has a split form that acts as the main form used. One of these split forms is able to be filtered from the datasheet portion of the split form using...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.