Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default query info based on dates

I have a spreadsheet in Excel 97 with 15 columns of information, one of
which is a date entry. Is it possible to create a macro that will show a box
in which to input a date range and then to bring back information from 7 of
the other columns based on the date selection, and paste the information
into a new workbook?

Any help or guidance greatly appreciated.
Regards
Martin


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default query info based on dates

Assume column C is the date column, row 1 has headers and data starts in A2.
Sheet2 in the workbook is blank

Dim res as variant
Dim lVal as Long
Dim sh as Worksheet

res = Inputbox("Enter a date")
if not isdate(res) then
msgbox "Bad date, exiting"
exit sub
End if

lVal = clng(cdate(res))

Range("A1").CurrentRegion.AutoFilter Field:=3, Criteria1:=lval
Activesheet.Autofilter.Range.Resize(,7).Copy _
Destination:=Worksheets("Sheet2").Range("A1")
Activesheet.Autofilter
set sh = worksheets("Sheet2")
sh.copy
sh.Cells.Clear

--
Regards,
Tom Ogilvy



martin wrote in message
...
I have a spreadsheet in Excel 97 with 15 columns of information, one of
which is a date entry. Is it possible to create a macro that will show a

box
in which to input a date range and then to bring back information from 7

of
the other columns based on the date selection, and paste the information
into a new workbook?

Any help or guidance greatly appreciated.
Regards
Martin




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default query info based on dates

Thanks.


"Tom Ogilvy" wrote in message
...
Assume column C is the date column, row 1 has headers and data starts in

A2.
Sheet2 in the workbook is blank

Dim res as variant
Dim lVal as Long
Dim sh as Worksheet

res = Inputbox("Enter a date")
if not isdate(res) then
msgbox "Bad date, exiting"
exit sub
End if

lVal = clng(cdate(res))

Range("A1").CurrentRegion.AutoFilter Field:=3, Criteria1:=lval
Activesheet.Autofilter.Range.Resize(,7).Copy _
Destination:=Worksheets("Sheet2").Range("A1")
Activesheet.Autofilter
set sh = worksheets("Sheet2")
sh.copy
sh.Cells.Clear

--
Regards,
Tom Ogilvy



martin wrote in message
...
I have a spreadsheet in Excel 97 with 15 columns of information, one of
which is a date entry. Is it possible to create a macro that will show a

box
in which to input a date range and then to bring back information from 7

of
the other columns based on the date selection, and paste the information
into a new workbook?

Any help or guidance greatly appreciated.
Regards
Martin






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
Need Macro- Insert rows based on dates and copy info from that row Katerinia Excel Discussion (Misc queries) 1 April 6th 10 08:02 PM
sum of info in a range based on dates Real esate guru Excel Worksheet Functions 4 September 15th 08 10:28 PM
Macro to put info into certain columns based on info in another co Studebaker Excel Discussion (Misc queries) 1 December 4th 07 05:27 PM
Sumproduct - Pulling info based on lenght of time between dates watchtower Excel Worksheet Functions 6 February 1st 07 01:42 PM
varying validation info based on preceding info georgejl Excel Discussion (Misc queries) 1 November 9th 06 10:31 PM


All times are GMT +1. The time now is 09:49 PM.

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"