Filtered Dates

rovman1

New Member
Joined
Nov 26, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I am taking on a task of which I have a function of filtering dates to extract data from another worksheet I have never done in VBA. I have two work books which are Project_Summary and Exp_Report, Exp_Report is a query from our PM Module and Project_Summary is a workbook I have built to provide high level and low level project financials in the following steps.

Within Project_Summary, I have a Sheet called Expenditures within which is "Task" and then "Date" which is formatted "mmmm-yyyy" (column D) to be used for criteria to move data from Exp_Report over. See below

1669478571483.png


Step 1: Within Project_Summary workbook I have VBA code that takes Exp_Report query and sorts/filters this query into a usable report. This part is working good

1669478693575.png


Step 2: Is to filter the data within Exp_Report by Task and Date then move filtered data to Workbook (Project_Summary) Sheet(Expenditures). I can filter Exp_Report "Task" without issues

Step 3: When I try to filter Exp_Report "Date" based on the dates from Expenditures "Column D" I only clear out all Dates. Below is the code for such I have come up with so far.

Variables I have set
Dim myDate As Date
Dim wsDest As Worksheet
Dim wsCopy As Worksheet
Set wsDest = ThisWorkbook.Sheets("Expenditures")
Set wsCopy = Workbooks("Exp_Report").Sheets("Sheet1")

This is the part of the code I need to use to filter the dates in the Exp_Report I am going to copy
myDate = Range("PMDATE7").Value
wsCopy.Range("$A$1:$G$10000").AutoFilter Field:=2, Criteria1:= _
"02 PROJECT MANAGEMENT"
wsCopy.Range("$A$1:$D$10000").AutoFilter Field:=4, Operator:= _
xlFilterValues, Criteria1:="myDate.Value"

I hope i have given enough information to help.
 

Attachments

  • 1669479216279.png
    1669479216279.png
    172.6 KB · Views: 7

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
I figured out my problem with the statement I was using and now have it working.

In case anyone runs into the issue, here is the solution

The statement below replaces my orginal staement; wsCopy.Range("$A$1:$G$124").AutoFilter Field:=4, Operator:= _
xlFilterValues, Criteria2:=Array(1, wsDest.Range("PMD_7"))

Original Statement;
wsCopy.Range("$A$1:$D$10000").AutoFilter Field:=4, Operator:= _
xlFilterValues, Criteria1:="myDate.Value"
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,818
Members
449,049
Latest member
cybersurfer5000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top