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

I'm trying to write a macro where if the date in cell A1 is the same as
today's date then the macro ends but if the cell is blank or has any other
date then it puts today's date in cell F2

The code is below but it isn't recognising where the date in A1 is the same
as today's - it continues to put today's date in F2.

I'm not sure what I've done wrong but I've tried a number of variations on a
theme without success so I'm stuck and would really appreciate some help.

Thanks a lot

-------------

Sub hats()
Range("a1").Select
If ActiveCell.Value = "=today()" Then
End
ElseIf ActiveCell.Value < "=today()" Then
Range("F2").Select
ActiveCell.FormulaR1C1 = "=today()"
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
End If

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default If Cell Contents =today() then....

Try
ActiveCell.Formula = "=today()"

or
ActiveCell.Value = Today

Cheers
Darren


On Oct 25, 10:44 am, nospaminlich
wrote:
I'm trying to write a macro where if the date in cell A1 is the same as
today's date then the macro ends but if the cell is blank or has any other
date then it puts today's date in cell F2

The code is below but it isn't recognising where the date in A1 is the same
as today's - it continues to put today's date in F2.

I'm not sure what I've done wrong but I've tried a number of variations on a
theme without success so I'm stuck and would really appreciate some help.

Thanks a lot

-------------

Sub hats()
Range("a1").Select
If ActiveCell.Value = "=today()" Then
End
ElseIf ActiveCell.Value < "=today()" Then
Range("F2").Select
ActiveCell.FormulaR1C1 = "=today()"
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
End If

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default If Cell Contents =today() then....

You seem to have made your sub unnecessarily complicated.

This sub will compare the date in cell A1 with the current date and if they
don't match it will enter the current date and time in cell f2.

Sub hats()
Range("a1").Select
If DatePart("y", ActiveCell.Value) < DatePart("y", Now()) Then
Range("F2").Select
Selection.Value = Now()
End If
End Sub

HTH

Andy W

"nospaminlich" wrote:

I'm trying to write a macro where if the date in cell A1 is the same as
today's date then the macro ends but if the cell is blank or has any other
date then it puts today's date in cell F2

The code is below but it isn't recognising where the date in A1 is the same
as today's - it continues to put today's date in F2.

I'm not sure what I've done wrong but I've tried a number of variations on a
theme without success so I'm stuck and would really appreciate some help.

Thanks a lot

-------------

Sub hats()
Range("a1").Select
If ActiveCell.Value = "=today()" Then
End
ElseIf ActiveCell.Value < "=today()" Then
Range("F2").Select
ActiveCell.FormulaR1C1 = "=today()"
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
End If

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default If Cell Contents =today() then....

Typo, VBA is Date not Today

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"darrenmcconachie" wrote in message
oups.com...
Try
ActiveCell.Formula = "=today()"

or
ActiveCell.Value = Today

Cheers
Darren


On Oct 25, 10:44 am, nospaminlich
wrote:
I'm trying to write a macro where if the date in cell A1 is the same as
today's date then the macro ends but if the cell is blank or has any

other
date then it puts today's date in cell F2

The code is below but it isn't recognising where the date in A1 is the

same
as today's - it continues to put today's date in F2.

I'm not sure what I've done wrong but I've tried a number of variations

on a
theme without success so I'm stuck and would really appreciate some

help.

Thanks a lot

-------------

Sub hats()
Range("a1").Select
If ActiveCell.Value = "=today()" Then
End
ElseIf ActiveCell.Value < "=today()" Then
Range("F2").Select
ActiveCell.FormulaR1C1 = "=today()"
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,

SkipBlanks:= _
False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
End If

End Sub




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default If Cell Contents =today() then....

Course it is. Silly me!!

Typo, VBA is Date not Today


On Oct 25, 12:25 pm, "Bob Phillips" wrote:


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"darrenmcconachie" wrote in ooglegroups.com...



Try
ActiveCell.Formula = "=today()"


or
ActiveCell.Value = Today


Cheers
Darren


On Oct 25, 10:44 am, nospaminlich
wrote:
I'm trying to write a macro where if the date in cell A1 is the same as
today's date then the macro ends but if the cell is blank or has any

other
date then it puts today's date in cell F2


The code is below but it isn't recognising where the date in A1 is the

same
as today's - it continues to put today's date in F2.


I'm not sure what I've done wrong but I've tried a number of variations

on a
theme without success so I'm stuck and would really appreciate some

help.

Thanks a lot


-------------


Sub hats()
Range("a1").Select
If ActiveCell.Value = "=today()" Then
End
ElseIf ActiveCell.Value < "=today()" Then
Range("F2").Select
ActiveCell.FormulaR1C1 = "=today()"
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,

SkipBlanks:= _
False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
End If


End Sub- Hide quoted text -- Show quoted text -


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
concatenate contents of cells whose contents resemble cell referem cathyh Excel Worksheet Functions 3 May 23rd 09 12:16 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
Macro to clear range contents when cell contents are changed by us Steve E Excel Programming 12 February 22nd 07 09:09 PM
Macro to remove contents of cell and move all other contents up one row adw223 Excel Discussion (Misc queries) 1 July 1st 05 03:57 PM
Copying cell contents to add to existing contents in another cell Dean Sawas Excel Programming 3 April 2nd 04 09:00 PM


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