gino59
Active Member
- Joined
- Jul 26, 2010
- Messages
- 496
Hi all,
I have the following bit of code that looks up a date range in a very large table and returns the data from that to a new table on a different sheet. The way I've got the code written, I have to manually change the date selection. I'm hoping some one knows a way around that!
Basically, I want to go to the master table and filter for a particular month (say April 2010). Then write the data for that month to the new table.
It works with this code but I'd like the user to be able to select a date (maybe from a calendar) and have the code return the data.
Hope that makes sense!
I have the following bit of code that looks up a date range in a very large table and returns the data from that to a new table on a different sheet. The way I've got the code written, I have to manually change the date selection. I'm hoping some one knows a way around that!
Basically, I want to go to the master table and filter for a particular month (say April 2010). Then write the data for that month to the new table.
It works with this code but I'd like the user to be able to select a date (maybe from a calendar) and have the code return the data.
Hope that makes sense!
Code:
Private Sub Macro1()
'
Sheets("mData").Activate
ActiveSheet.ListObjects("mData").Range.AutoFilter field:=1, Operator:= _
xlFilterValues, Criteria2:=Array(1, "3/31/2011")
Range("mData[DATE],mData[[ACCOUNT]:[DEPOSIT]]").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Activate
Range("ThisMONTHtx[[DATE]:[DEPOSIT]]").Select
ActiveSheet.Paste
Sheets("mData").Activate
ActiveSheet.ListObjects("mData").Range.AutoFilter field:=1
Sheets("Sheet1").Activate
Range("C20").Activate
End Sub