Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 208
Default run a macro for a selected date

I want to run a macro that extracts data from a master spreadsheet into a new
file. This is no problem.
Within the master Spreadsheet(MSS) I have columns b- ca. One column is a
date.
What I want is the extra command that will allow me run the macro that will
allow me to select only a particular date. but I want to be able to select
the date when asked.
can the macro be written so at some stage it comes up with a message what
date do you want to select? and for me to type the date in and enter for the
rest of the macro to continue

Regards

Sean...
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default run a macro for a selected date

"Sean" wrote in message
...
I want to run a macro that extracts data from a master spreadsheet into a
new
file. This is no problem.
Within the master Spreadsheet(MSS) I have columns b- ca. One column is a
date.
What I want is the extra command that will allow me run the macro that
will
allow me to select only a particular date. but I want to be able to select
the date when asked.
can the macro be written so at some stage it comes up with a message what
date do you want to select? and for me to type the date in and enter for
the
rest of the macro to continue


Yes. See Excel (VBA) Help for "InputBox Method".


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 208
Default run a macro for a selected date

Andy,
I need to filter the spreadsheet that over 2000 rows by one date that will
select 25 enteries
I have as part of the macro a comand that says
Selection.Autofilter
Selection.Autofilter Field:=2, Criterial:-"active"
which works great but I need to filter field 9 or column j by a selected
date, which I need to choose

"Andy Brown" wrote:

"Sean" wrote in message
...
I want to run a macro that extracts data from a master spreadsheet into a
new
file. This is no problem.
Within the master Spreadsheet(MSS) I have columns b- ca. One column is a
date.
What I want is the extra command that will allow me run the macro that
will
allow me to select only a particular date. but I want to be able to select
the date when asked.
can the macro be written so at some stage it comes up with a message what
date do you want to select? and for me to type the date in and enter for
the
rest of the macro to continue


Yes. See Excel (VBA) Help for "InputBox Method".



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default run a macro for a selected date

"Sean" wrote in message
...
Andy,
I need to filter the spreadsheet that over 2000 rows by one date that will
select 25 enteries
I have as part of the macro a comand that says
Selection.Autofilter
Selection.Autofilter Field:=2, Criterial:-"active"
which works great but I need to filter field 9 or column j by a selected
date, which I need to choose


This line will prompt for the selected date:

FilterDate = CDate(Application.InputBox("Enter filter date"))

Over here I need to use CDate -- you may not. Then you could just add
another filter line after your Field:=2 line:

Selection.AutoFilter Field:=10, Criteria1:=FilterDate

But you may need/prefer to use an If/End if to check whether any records do
actually match FilterDate in column J -- something like:

If WorksheetFunction.CountIf(Range("J1", Range("J" & Rows.Count).End(xlUp)),
FilterDate) 0 Then
Selection.AutoFilter Field:=10, Criteria1:=FilterDate
End If

HTH,
Andy


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 208
Default run a macro for a selected date

Brilliant - Thanks

"Andy Brown" wrote:

"Sean" wrote in message
...
Andy,
I need to filter the spreadsheet that over 2000 rows by one date that will
select 25 enteries
I have as part of the macro a comand that says
Selection.Autofilter
Selection.Autofilter Field:=2, Criterial:-"active"
which works great but I need to filter field 9 or column j by a selected
date, which I need to choose


This line will prompt for the selected date:

FilterDate = CDate(Application.InputBox("Enter filter date"))

Over here I need to use CDate -- you may not. Then you could just add
another filter line after your Field:=2 line:

Selection.AutoFilter Field:=10, Criteria1:=FilterDate

But you may need/prefer to use an If/End if to check whether any records do
actually match FilterDate in column J -- something like:

If WorksheetFunction.CountIf(Range("J1", Range("J" & Rows.Count).End(xlUp)),
FilterDate) 0 Then
Selection.AutoFilter Field:=10, Criteria1:=FilterDate
End If

HTH,
Andy





  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default run a macro for a selected date

"Sean" wrote in message
...
Brilliant - Thanks


No problem -- thanks for the feedback. :)


  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default run a macro for a selected date

PS: you'll have to be careful with the format of the input date tho' --
Excel may well see it as US-style (mm-dd-yy).

IIRC, John Green covered this somewhere -- search Google Groups for "john
green US-centric cdate".


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
Tracking Date Changes lee Excel Discussion (Misc queries) 5 November 2nd 06 11:43 PM
Advanced Filtering by Date (or Macro) Help Alexis Excel Worksheet Functions 1 March 8th 06 05:09 PM
Perform oiperations relative to initial selected cell scratching my head Excel Discussion (Misc queries) 1 May 30th 05 05:42 PM
How do I insert the date using a macro tara0801 Excel Discussion (Misc queries) 4 February 10th 05 09:09 PM
Date and Time Macro m.j.anderson Excel Discussion (Misc queries) 1 December 1st 04 12:35 AM


All times are GMT +1. The time now is 12:53 PM.

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

About Us

"It's about Microsoft Excel"