Solved

Excel 2012  VBA Named range into an Array

Posted on 2014-09-10
1
370 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 48

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

762 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

17 Experts available now in Live!

Get 1:1 Help Now