Solved

Excel 2012  VBA Named range into an Array

Posted on 2014-09-10
1
373 Views
Last Modified: 2014-09-26
Hi Experts

I have a named range in Excel that values I want to assing to an AutoFilter.

If I records a Macro I get the filter syntax as -

        ActiveSheet.Range("$A$1:$Y$8340").AutoFilter Field:=1, Criteria1:=Array( _
         "A", "B", "C", "D), Operator:=xlFilterValues

So i'm assuiming that I need to replace the Array() in the above syntax with something like

Dim strName() As Variant

strName= Range("FundList").Value


    Sheets("Trades").Select
    ActiveSheet.Range("$A$1:$Y$8340").AutoFilter Field:=1, Criteria1:=Array( _
          strName), Operator:=xlFilterValues

However the above doesnt run.

Any ideas?

The range "Name" is one coloumn of about ten rows of data.
0
Comment
Question by:MrDavidThorn
1 Comment
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40314394
Hi,

pls try

Dim varName As Variant
Dim arrName
varName = Range("FundList")
arrName = WorksheetFunction.Index(WorksheetFunction.Transpose(varName), 1, 0)
ActiveSheet.Range("$A$1:$Y$8340").AutoFilter Field:=1, Criteria1:=arrName, _
         Operator:=xlFilterValues

Regards
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now