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 7962281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:17:56+00:00 2026-06-04T05:17:56+00:00

I’ve got a spreadsheet in my Excel 2010 workbork with a lot of data.

  • 0

I’ve got a spreadsheet in my Excel 2010 workbork with a lot of data. This page can be sorted by the build in autofilter.
On another sheet I have made a button which does some of the sorting.
For example:

Sub forsteKvartalAftaleIndgaet()

'
    Sheets("AMRM01").Select
    ActiveSheet.Range("$A$12:$P$76").AutoFilter Field:=2, Criteria1:="<01-04", _
        Operator:=xlAnd
    Sheets("Ark2").Select
End Sub

Sub andenKvartalAftaleIndgaet()
'

    Sheets("AMRM01").Select
    ActiveSheet.Range("$A$12:$P$76").AutoFilter Field:=2, Criteria1:=">01-04", _
        Operator:=xlAnd, Criteria2:="<01-07"
    Sheets("Ark2").Select
End Sub

When I do this the sheet shows the first and second quarter of the year. I’ve got two buttons which show the third quarter and fourth quarter of the year which looks like this:

Sub TredjeKvartalAftaleIndgaet()
'

    Sheets("AMRM01").Select
    ActiveSheet.Range("$A$12:$P$76").AutoFilter Field:=2, Criteria1:=">01-07", _
        Operator:=xlAnd, Criteria2:="<01-10"
    Sheets("Ark2").Select
End Sub


Sub FjerdeKvartalAftaleIndgaet()
'

    Sheets("AMRM01").Select
    ActiveSheet.Range("$A$12:$P$76").AutoFilter Field:=2, Criteria1:=">01-10", _
        Operator:=xlAnd, Criteria2:="<31-12"
    Sheets("Ark2").Select
End Sub

My problem: When I press the button (Second quarter) it filters and shows the second quarter. But when I press the “Third Quarter” button it removes the Second Quarter filter and shows the Third Quarter.

Is it possible to write some kind of VBA code which makes it possible to have both buttons pressed at the same time, like it’s possible to do with the build in autofilter buttons?

If you’re not quite sure what I mean, please ask for a better explanation.

Thanks in advance

  • 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-04T05:17:57+00:00Added an answer on June 4, 2026 at 5:17 am

    Something like this perhaps? So it stands true for both ways? i.e.if

    1) You select 2nd quarter first then it will show 2nd quarter and then when you press 3rd quarter, it will show you 2nd and 3rd quarter.

    2) You select 3rd quarter first then it will show 3rd quarter and then when you press 2nd quarter, it will show you 2nd and 3rd quarter.

    Note: I have not tested the code so let me know if you get any errors 🙂

    Dim strCrt1 As String, strCrt2 As String, strCrt3 As String, strCrt4 As String
    
    Sub andenKvartalAftaleIndgaet()
        strCrt1 = ">01-04"
        strCrt2 = "<01-07"
    
        With Sheets("AMRM01")
            If strCrt4 <> "" Then
                .Range("$A$12:$P$76").AutoFilter Field:=2, _
                Criteria1:=strCrt1, Operator:=xlAnd, _
                Criteria2:=strCrt4
            Else
                .Range("$A$12:$P$76").AutoFilter Field:=2, _
                Criteria1:=strCrt1, Operator:=xlAnd, _
                Criteria2:=strCrt2
            End If
        End With
    End Sub
    
    Sub TredjeKvartalAftaleIndgaet()
        strCrt3 = ">01-04"
        strCrt4 = "<01-07"
    
        With Sheets("AMRM01")
            If strCrt1 <> "" Then
                .Range("$A$12:$P$76").AutoFilter Field:=2, _
                Criteria1:=strCrt1, Operator:=xlAnd, _
                Criteria2:=strCrt4
            Else
                .Range("$A$12:$P$76").AutoFilter Field:=2, _
                Criteria1:=strCrt3, Operator:=xlAnd, _
                Criteria2:=strCrt4
            End If
        End With
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace

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.