Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Criteria Macro

Hi,

I am using the below macro to filter for data between two dates. I
there a way that the code can be adpted so that the start data and en
date only needs to be entered once and can then take extracts for thos
values from all worksheets\books

Dim rng As Range
Dim rng2 As Range
Dim strStart As String
Dim strEnd As String

GetForm:
Sheets("extract").Visible = True
Sheets("Purchasing").Select

strStart = InputBox("Please enter start date, (dd/mm/yyyy)", "Tur
Around checker: Start Date")
strEnd = InputBox("Please enter end date, (dd/mm/yyyy)", "Turn Aroun
Checker: End Date")
Selection.AutoFilter Field:=2, Criteria1:="="
CLng(CDate(strStart)), Operator:=xlAnd, _
Criteria2:="<=" & CLng(CDate(strEnd))
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng2 = .SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With

Worksheets("extract").Cells.Clear
Set rng = ActiveSheet.AutoFilter.Range
rng.Copy Destination:=Worksheets("extract").Range("A1"

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Criteria Macro

Hi
one way would be the use of two cells in your workbook. lets say A1 and
A2 on shet one. Change the lines
strStart = InputBox("Please enter start date, (dd/mm/yyyy)", "Turn
Around checker: Start Date")
strEnd = InputBox("Please enter end date, (dd/mm/yyyy)", "Turn Around
Checker: End Date")

to
strStart = Activeworkbook.worksheets("Sheet1").range("A1").va lue
strEnd = Activeworkbook.worksheets("Sheet1").range("A2").va lue

--
Regards
Frank Kabel
Frankfurt, Germany
"pauluk " schrieb im
Newsbeitrag ...
Hi,

I am using the below macro to filter for data between two dates. Is
there a way that the code can be adpted so that the start data and

end
date only needs to be entered once and can then take extracts for

those
values from all worksheets\books

Dim rng As Range
Dim rng2 As Range
Dim strStart As String
Dim strEnd As String

GetForm:
Sheets("extract").Visible = True
Sheets("Purchasing").Select

strStart = InputBox("Please enter start date, (dd/mm/yyyy)", "Turn
Around checker: Start Date")
strEnd = InputBox("Please enter end date, (dd/mm/yyyy)", "Turn Around
Checker: End Date")
Selection.AutoFilter Field:=2, Criteria1:="=" &
CLng(CDate(strStart)), Operator:=xlAnd, _
Criteria2:="<=" & CLng(CDate(strEnd))
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng2 = .SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With

Worksheets("extract").Cells.Clear
Set rng = ActiveSheet.AutoFilter.Range
rng.Copy Destination:=Worksheets("extract").Range("A1")


---
Message posted from http://www.ExcelForum.com/


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
a macro with finishing criteria driller2 Excel Discussion (Misc queries) 2 October 13th 09 06:20 AM
Macro copy with criteria puiuluipui Excel Discussion (Misc queries) 8 September 19th 09 11:30 AM
MACRO: Add formula's across row if criteria is met SteveT Excel Discussion (Misc queries) 3 August 30th 07 02:00 PM
Can a macro erase it's self after a set criteria? Jeff Excel Worksheet Functions 3 October 13th 05 10:01 AM
Start and end criteria macro xsilverx Excel Programming 4 December 29th 03 03:13 PM


All times are GMT +1. The time now is 02:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"