+ Reply to Thread
Results 1 to 2 of 2

vba macro filter based on a array of cells with text and number values

  1. #1
    Registered User
    Join Date
    01-22-2014
    Location
    madrid
    MS-Off Ver
    Excel 2010
    Posts
    2

    Question vba macro filter based on a array of cells with text and number values

    Hi all,

    I'm stuck at the moment with the following problem. I have researching and googling for a solution without a proper outcome...

    Working with vba excel 2010

    I have a workbook with two main tabs: PurchaseReport and CeCos_Tab

    The PurchaseReport contains a range of cells where the first column have different elements, including numbers (figures) and texts (strings).

    The CeCos_Tab has the list of elemenets (criteria) to be used to filter the former column.

    There is an object defined which is: CritList=OFFSET(Criterias,1,0,COUNTA(CeCos_Tab!$A:$A)-1,1); note Criterias is the header of that list: Criterias=CeCos_Tab!$A$1. Assume it's working properly as I have already checked.

    As said the criteria list contains numbers and text values, here is a sample. Criterias: test0, 1, test1, 2, 3, 4, 5, 6, 7 and test2.

    My code is:

    Sub FilterRangeCriteria()
    Dim vCrit As Variant
    Dim wsO As Worksheet
    Dim wsL As Worksheet
    Dim rngCrit As Range
    Dim rngOrders As Range

    Set wsO = Worksheets("PurchaseReport")
    Set wsL = Worksheets("CeCos_Tab")
    Set rngOrders = wsO.Range("$A$1").CurrentRegion
    Set rngCrit = wsL.Range("CritList")

    vCrit = rngCrit.Value

    If wsO.FilterMode Then
    wsO.ShowAllData
    End If

    rngOrders.AutoFilter _
    Field:=1, _
    Criteria1:=Application.Transpose(vCrit), _
    Operator:=xlFilterValues
    End Sub

    The filter only presents text (string) values of the criteria list; in my example: test0, test1 and test2

    If the Criteria1 is "Criteria1:=Split(Join(Application.Transpose(vCrit))), _" the filter only offers the numbers (figures) values of the criteria list; in my example: 1, 2, 3, 4, 5, 6 and 7

    How can I get both the texts values and the numbers in my filter criteria: test0, 1, test1, 2, 3, 4, 5, 6, 7, test2

    Many thanks in advance! David

  2. #2
    Registered User
    Join Date
    01-22-2014
    Location
    madrid
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: vba macro filter based on a array of cells with text and number values

    Can anybody help me here? I'm still stuck with this problem and I cannot progress in my coding....
    Many thanks in advance,
    David D

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Counting the number of entries in an array having cells with multiple values
    By RAHUL_MOHAN in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-10-2013, 07:20 AM
  2. [SOLVED] Return array of values based on text
    By djm601 in forum Excel General
    Replies: 4
    Last Post: 11-19-2012, 11:09 AM
  3. Replies: 2
    Last Post: 06-13-2012, 11:20 AM
  4. Filter sheet then assign values into array based on this filtered sheet
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2011, 10:32 AM
  5. Replies: 2
    Last Post: 07-10-2008, 05:53 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1