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

  • Home
  • SEARCH
  • 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 4268258
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:00:42+00:00 2026-05-21T07:00:42+00:00

I have this code and i want do filter the autofill results by two

  • 0

I have this code and i want do filter the autofill results by two dates (ex: from 01-01-2009 to 02-10-2010). How can i do this? Does anybody have a clue? The code bellow is simplified (the current one only have more Ranges). I´ve tried to add condidions in the If Function but i only get error… thanks for your help. By the way i had a great help for this code so i´m a litte noob in excel macro vba :).

The dimResult1, clean1 etc stands for the date values. What i can´t do is to skip to nextcell if oCellResult1.Offset(iCellCount, 0).Value = oCell.Offset(0, 4).Value isn´t between the two dates.

Private Sub Worksheet_Change(ByVal Target As Range)

Dim oCell As Excel.Range
Dim oCellResult1 As Excel.Range
Dim oCellResult2 As Excel.Range
Dim oCellClean1 As Excel.Range
Dim oCellClean2 As Excel.Range
Dim oRangeID As Excel.Range
Dim iCellCount As Integer


If Target.Address = "$T$4" Then

    'Set source data
    Set oRangeID = Sheets("Registo_EPI").Range("A3:A5000")

    'Define initial target for the results obtained
    'data
    Set oCellResult1 = Sheets("Distribuição_EPI").Range("U12") 
    'luvas
    Set oCellResult2 = Sheets("Distribuição_EPI").Range("E12") 

    'Clear up any previous data
    Set oCellClean1 = oCellResult1
    Set oCellClean2 = oCellResult2
    While Len(oCellClean1.Value) > 0

        oCellClean1.ClearContents
        Set oCellClean1 = oCellClean1.Offset(1, 0)

        oCellClean2.ClearContents
        Set oCellClean2 = oCellClean2.Offset(1, 0)

    Wend

    'Scans source range for match data
    For Each oCell In oRangeID

        If oCell.Value = "" Then Exit For

        If oCell.Value = Target.Value Then

           'data
           oCellResult1.Offset(iCellCount, 0).Value = oCell.Offset(0, 4).Value 
           'luvas
           oCellResult2.Offset(iCellCount, 0).Value = oCell.Offset(0, 9).Value 
           iCellCount = iCellCount + 1

           If iCellCount = 14 Then iCellCount = iCellCount + 20


        End If

    Next oCell

End If

End Sub
  • 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-05-21T07:00:43+00:00Added an answer on May 21, 2026 at 7:00 am

    If I understood correctly what you’re trying to achieve, we can add a new condition in our IF statement.

    It would be something like:

        'Ensure the value in oCell is a date; otherwise the comparison won't work
        If oCell.Value = Target.Value and IsDate(oCell.Value) Then
    
            'Date Comparison
            if cDate(oCell.Value) > cdate("01-01-2009") and _
                cDate(oCell.Value) < ("02-10-2010") then
    
                'data
                oCellResult1.Offset(iCellCount, 0).Value = oCell.Offset(0, 4).Value 
                'luvas
                oCellResult2.Offset(iCellCount, 0).Value = oCell.Offset(0, 9).Value 
                iCellCount = iCellCount + 1
    
                If iCellCount = 14 Then iCellCount = iCellCount + 20
    
            end if
    
        End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have applied a template filter, which extracts the domain from an email address.
I have a report that uses a Multi Value parameter. I have added this
how can I run ruby code inside javascript in haml? if I use var
I have a filter object to query a table with many columns, and rather
i am leveraging this project to use jqgrid to filter and sort collections .
Is there any way that I can filter some properties of an extends class?
I have the following function that fades each line of an unordered-list in and
Array( [MainArray]=>Array ( [myarray] => Array ( [0] => Array ( [id] => 1234
private ObservableCollection<OrganizationUnit> _Organizations = new ObservableCollection<OrganizationUnit>(); private ObservableCollection<OrganizationUnit> _OrganizationManagement; _OrganizationManagement = new ObservableCollection<OrganizationUnit>(_Organizations.Where(p =>

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.