Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Put current date into a cell when a macro is run

I want to set the value of a cell to the current date when a macro is run
without actually selecting the date (if possible).
Here's what I'm trying to use and it's not working. .

Dim LastPaid As Range
Set LastPaid = wks.Range("N2")
Set LastPaid = Value.Now()

I know this is probably simple but it has me perplexed.

Than ks
Jonco


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Put current date into a cell when a macro is run

Hi Jonco,

Try something like:

'=============
Public Sub Tester()
Dim wks As Worksheet
Dim LastPaid As Range

Set wks = ThisWorkbook.Worksheets("Sheet1")
Set LastPaid = wks.Range("N2")

LastPaid.Value = Date
End Sub
'<<=============


---
Regards,
Norman



"jonco" wrote in message
y.net...
I want to set the value of a cell to the current date when a macro is run
without actually selecting the date (if possible).
Here's what I'm trying to use and it's not working. .

Dim LastPaid As Range
Set LastPaid = wks.Range("N2")
Set LastPaid = Value.Now()

I know this is probably simple but it has me perplexed.

Than ks
Jonco



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Put current date into a cell when a macro is run


Hi There jonco

Heres what i would do

Sub insertdate()
Range("N2").Select
ActiveCell.FormulaR1C1 = "=TODAY()"
End Sub

This would return todays date in short format i.e 14/07/06(for
australia). if you want this date to remain as 14/07/06 and not update
as the date changes i would suggest adding the following to the macro
:

Range("N2").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

This just copies the date and pastes it as a value so it wont change
every day.

Let me know if this works or not :-)

Steel Monkey


--
Steel Monkey
------------------------------------------------------------------------
Steel Monkey's Profile: http://www.excelforum.com/member.php...o&userid=29051
View this thread: http://www.excelforum.com/showthread...hreadid=561327

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Put current date into a cell when a macro is run

Give this one a go...

Sub dataInCell ()

Cells(1, 1).Value = Format(Now(), "mm/dd/yyyy h:mm:ss")

End Sub

Here the (1, 1) are for cell "A1". You can change up the format to exclude the time factor if you like.
--
Mark Ivey
"jonco" wrote in message y.net...
I want to set the value of a cell to the current date when a macro is run
without actually selecting the date (if possible).
Here's what I'm trying to use and it's not working. .

Dim LastPaid As Range
Set LastPaid = wks.Range("N2")
Set LastPaid = Value.Now()

I know this is probably simple but it has me perplexed.

Than ks
Jonco


  #5   Report Post  
Posted to microsoft.public.excel.programming
jb jb is offline
external usenet poster
 
Posts: 4
Default Put current date into a cell when a macro is run

You might also try:


' Macro Wrote: 9/24/2002 by J. B. MOSS
'
Range("H30").Select
SendKeys "^;~", True ' Send Ctrl + ;(DATE)
Range("I30").Select
SendKeys "^+:~", True ' Send Ctrl + :(TIME)
Range("A5").Select


"jonco" wrote in message
y.net...
I want to set the value of a cell to the current date when a macro is run
without actually selecting the date (if possible).
Here's what I'm trying to use and it's not working. .

Dim LastPaid As Range
Set LastPaid = wks.Range("N2")
Set LastPaid = Value.Now()

I know this is probably simple but it has me perplexed.

Than ks
Jonco





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Put current date into a cell when a macro is run

Thanks for the suggestions guys. I'll give these a try.

Jonco

"jonco" wrote in message
y.net...
I want to set the value of a cell to the current date when a macro is run
without actually selecting the date (if possible).
Here's what I'm trying to use and it's not working. .

Dim LastPaid As Range
Set LastPaid = wks.Range("N2")
Set LastPaid = Value.Now()

I know this is probably simple but it has me perplexed.

Than ks
Jonco



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
Run a macro in active cell only. Want to place current date/time. time clock watcher Excel Worksheet Functions 3 July 20th 09 07:46 AM
Macro to Insert Current Date into cell - Macro to "Save As" Guy[_2_] Excel Worksheet Functions 4 December 12th 08 08:20 PM
save workbook as current date using a macro ExcelJon Excel Discussion (Misc queries) 2 June 21st 06 03:05 AM
How do you set cursor position at current date in macro? Tom Robertson Excel Worksheet Functions 1 May 28th 06 03:50 PM
A macro for the today's date...not the current date abxy[_18_] Excel Programming 7 February 8th 04 11:05 PM


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