Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9125013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:42:09+00:00 2026-06-17T06:42:09+00:00

Been looking around a bit and haven’t found a proper solution as yet, so

  • 0

Been looking around a bit and haven’t found a proper solution as yet, so here’s my question! Still rather new to this, forgive me for any improper vocabulary.

I’m attempting to make a filter for data similar to the following:

8.5 x 11
8.3 x 10.9
8.7 x 10.9
8.3 x 10.9
11 x 8.5
8.5 x 11
8.5 x 11
15 x 11

Basically I need to be able to filter by the first value AND the second value. With a great deal of help from a member of Stackoverflow, I’ve sorted out placing these values into an array, determining the first and second value and assign them as Arrval(0) and Arrval(1) and then assign those oto the variables “small” and “large” based on the dimensions. That way if the first side is larger, etc. it still works out. Here is what think is the pertinent code in regards to that:

val = Trim(arr(r, 1))
    If val Like "*x*" Then
        Arrvals = Split(val, "x")
        V1 = Trim(Arrvals(0))
        V2 = Trim(Arrvals(1))
        If IsNumeric(V1) And IsNumeric(V2) Then
            V1 = CDbl(V1)
            V2 = CDbl(V2)
                            If V1 > V2 Then
                Small = V2: Large = V1
            Else
                Small = V1: Large = V2
            End If
            End If
            End If

Subsequently I use these values to determine the dimensions of a “size” and count it if it meets certain parameters. e.g.

testcase8511 = Small <= 9.9 And Large <= 14.5
test117 = Small >= 10 And Large <= 17.6

I then count these using an if-else statement (just using if x then range.value = range.value +1) and change the color of the row they are present in.

Long story short (was hoping to give enough background to make this easier!) I need to be able to filter by these parameters and then export the results to a text file. I’ve got the text export mostly sorted out, but I can’t figure out how to filter properly. I suspect it’s mostly a syntax issue.

The quick and dirty way is to just have another cell in the row where these variables are true get an “x” or “y” or some other marker added to them when I’m doing the counting and then filter by that, but I suspect there is a better/more efficient/less resource intensive way to do this for someone who has more of a clue than I do. I don’t even know if literally using an autofilter, exporting and then turning the autofilter back off is the best way to do this. Since these rows are being color, I suppose I could also filter by the interior color of a cell or something else. Just not sure where to go to get this done properly.

So basically, in summary I need to be able to do

  1. filter by one of my above variables (e.g. testcase8511) after I’ve gone through all the data and counted them if true. (is there a way to store this info in VBA that makes sense resource wise? I doubt it, dunno.)
  2. Export this filtered data to text file (which I’ve mostly sorted for myself)
  3. Return the workbook (or leave it) visually the same. i.e. I don’t want this filter to be visually present to the user after the export process is completed.
  4. Do this as efficiently as possible, program wise (admittedly, I doubt anybody willing to answer would aspire to do otherwise). Some of the computers we’re using are… not great.

Thanks in advance! I’ll clarify anything I didn’t explain well if. Ask away.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:42:10+00:00Added an answer on June 17, 2026 at 6:42 am

    Okay, here’s one solution for the filtering:
    In the Worksheet-Module:

    Sub test()
        Dim i As Long
        Dim f1 As String, f2 As String
        Dim f As String
        Dim c As New Collection
        Dim arr() As String
    
        f = InputBox("Enter two filters with comma, e.g. '>3.2, <10", "Filters")
        If InStr(f, ",") = 0 Then Exit Sub
        f1 = Split(f, ",")(0)
        f2 = Split(f, ",")(1)
    
        For i = 2 To Me.UsedRange.Rows.Count
            If xFilter(f1, f2, Me.Cells(i, "A").Text) Then c.Add Me.Cells(i, "A").Text
        Next
        If Not Me.AutoFilterMode Then Me.Rows(1).AutoFilter
    
        ReDim arr(c.Count - 1)
        For i = 1 To c.Count
            arr(i - 1) = c(i)
        Next
        Me.UsedRange.AutoFilter Field:=1, Criteria1:=arr, Operator:=xlFilterValues
    
    End Sub
    

    (Field is the column number, must match with Cell(i, "A") above)

    In a Module:

    Public Function xFilter(f1 As String, f2 As String, t As String) As Boolean
        Dim v1 As Double
        Dim v2 As Double
        Dim r1 As Boolean
        Dim r2 As Boolean
    
        v1 = Val(Split(t, "x")(0))
        v2 = Val(Split(t, "x")(1))
    
        r1 = Evaluate( _
            WorksheetFunction.Text(v1, "0.0########") & f1)
        r2 = Evaluate( _
            WorksheetFunction.Text(v2, "0.0########") & f2)
        xFilter = r1 And r2
    End Function
    

    It seems to do the trick “OK”.
    (I have used WorksheetFunction.Text because CStr gives a localized string like 3,5 in German.)
    From a practical perspective however, I would personally stick with the rule: If you want to work with numbers as numbers, they should be numbers! So I would rather do split the values into two columns and work with ‘normal’ numeric filters on these. (A sub for that would work pretty similar to the one here…)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question has been asked a bit before. But looking around I
I've been Googling around a bit for an answer and haven't found a definitive
Been looking around a bit and I can't seem to find any help on
I've been looking around quite a bit to solve my issue. I got many
I've been looking around for a solution for several hours now, and maybe I'm
I have been looking around a bit for info on how to do this.
I have been looking around the site a bit, but I didn't find any
I've been looking around the web and have found a great deal of information
I have been looking around here and There , and I have become curious.
Hey i've been looking around for a while now and i still cant find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.