Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default =today() - 1

I have a macro with the following code that I am trying to run so that it
will select the date before today. I tried inserting <=today() - 1
Unfortunately the macro bombs.

Cells.Select
Selection.AutoFilter
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
Selection.AutoFilter Field:=10, Criteria1:=today() - 1

ActiveCell.SpecialCells(xlLastCell).Select
Range("A1:J14597").Select
Range("J14597").Activate
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
End Sub

Thanks for your help.

Fred
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default =today() - 1

One way:

With ActiveSheet.UsedRange
.AutoFilter
.AutoFilter _
Field:=10, _
Criteria1:=Format(Date - 1, "mm/dd/yyyy")
.Copy
End With
Workbooks.Add
With ActiveSheet
.Paste
.UsedRange.EntireColumn.AutoFit
End With

In article ,
fgwiii wrote:

I have a macro with the following code that I am trying to run so that it
will select the date before today. I tried inserting <=today() - 1
Unfortunately the macro bombs.

Cells.Select
Selection.AutoFilter
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
Selection.AutoFilter Field:=10, Criteria1:=today() - 1

ActiveCell.SpecialCells(xlLastCell).Select
Range("A1:J14597").Select
Range("J14597").Activate
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
End Sub

Thanks for your help.

Fred

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default =today() - 1

This is failing (I think) because the values in the date field =
5/16/2007 0:00
5/15/2007 0:00
5/14/2007 0:00
5/16/2007 0:00
Would a different syntax be used in this case?

Thank you

Fred
"JE McGimpsey" wrote:

One way:

With ActiveSheet.UsedRange
.AutoFilter
.AutoFilter _
Field:=10, _
Criteria1:=Format(Date - 1, "mm/dd/yyyy")
.Copy
End With
Workbooks.Add
With ActiveSheet
.Paste
.UsedRange.EntireColumn.AutoFit
End With

In article ,
fgwiii wrote:

I have a macro with the following code that I am trying to run so that it
will select the date before today. I tried inserting <=today() - 1
Unfortunately the macro bombs.

Cells.Select
Selection.AutoFilter
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
Selection.AutoFilter Field:=10, Criteria1:=today() - 1

ActiveCell.SpecialCells(xlLastCell).Select
Range("A1:J14597").Select
Range("J14597").Activate
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
End Sub

Thanks for your help.

Fred


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default =today() - 1

from
Criteria1:=Format(Date - 1, "mm/dd/yyyy")
to
Criteria1:=Format(Date - 1, "mm/dd/yyyy h:mm")

"fgwiii" wrote:

This is failing (I think) because the values in the date field =
5/16/2007 0:00
5/15/2007 0:00
5/14/2007 0:00
5/16/2007 0:00
Would a different syntax be used in this case?

Thank you

Fred
"JE McGimpsey" wrote:

One way:

With ActiveSheet.UsedRange
.AutoFilter
.AutoFilter _
Field:=10, _
Criteria1:=Format(Date - 1, "mm/dd/yyyy")
.Copy
End With
Workbooks.Add
With ActiveSheet
.Paste
.UsedRange.EntireColumn.AutoFit
End With

In article ,
fgwiii wrote:

I have a macro with the following code that I am trying to run so that it
will select the date before today. I tried inserting <=today() - 1
Unfortunately the macro bombs.

Cells.Select
Selection.AutoFilter
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
Selection.AutoFilter Field:=10, Criteria1:=today() - 1

ActiveCell.SpecialCells(xlLastCell).Select
Range("A1:J14597").Select
Range("J14597").Activate
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
End Sub

Thanks for your help.

Fred


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default =today() - 1

It looks like its failing because of the field number. It is a typo 10
should be 1.

"fgwiii" wrote:

This is failing (I think) because the values in the date field =
5/16/2007 0:00
5/15/2007 0:00
5/14/2007 0:00
5/16/2007 0:00
Would a different syntax be used in this case?

Thank you

Fred
"JE McGimpsey" wrote:

One way:

With ActiveSheet.UsedRange
.AutoFilter
.AutoFilter _
Field:=10, _
Criteria1:=Format(Date - 1, "mm/dd/yyyy")
.Copy
End With
Workbooks.Add
With ActiveSheet
.Paste
.UsedRange.EntireColumn.AutoFit
End With

In article ,
fgwiii wrote:

I have a macro with the following code that I am trying to run so that it
will select the date before today. I tried inserting <=today() - 1
Unfortunately the macro bombs.

Cells.Select
Selection.AutoFilter
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
Selection.AutoFilter Field:=10, Criteria1:=today() - 1

ActiveCell.SpecialCells(xlLastCell).Select
Range("A1:J14597").Select
Range("J14597").Activate
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
End Sub

Thanks for your help.

Fred


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
=TODAY() Amy Excel Discussion (Misc queries) 5 January 24th 08 12:25 AM
Before today MAustin Excel Discussion (Misc queries) 2 October 2nd 07 04:54 PM
IF TODAY equals date in cell A10, or if TODAY is beyond that date SoupNazi Excel Worksheet Functions 4 April 23rd 07 01:14 AM
=IF(OR(TODAY()G9),"Pass","Overdue") Why doe it not wo. Fkor Excel Discussion (Misc queries) 3 March 10th 05 08:29 AM
VBA - Today() not available in VBA? Byrt Martinez Excel Programming 1 January 30th 04 02:38 AM


All times are GMT +1. The time now is 09:17 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"