Solved

Excel 2012  VBA Named range into an Array

Posted on 2014-09-10
1
381 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 50

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

830 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