Take a look at the example attached.  If you press Alt+F11 to view the code,
you'll see that I attached the code to the Worksheet_SelectionChange event.
 This fires whenever someone selects a new cell on Sheet1 (in this case).
 Additionally, I added two lines to prohibit the timestamp from being
changed once already in place, or if you already have data on that line. (In
my example -- I'm assuming you have more data than just a date & time in
subsequent columns).

Enjoy,
Chris

On Thu, Feb 25, 2010 at 8:05 PM, Dave Bonallack
<davebonall...@hotmail.com>wrote:

>  Hi Billy,
> Not quite sure of your actual need.
> Here's the syntax for putting time or date into a cell using VBA
> Range("A1") = Date
> Range("B1") = Time
> If you want them to insert automatically, you'll have to let us know the
> conditions.
> Regards - Dave.
>
> > Date: Thu, 25 Feb 2010 16:11:41 -0800
> > Subject: $$Excel-Macros$$ Need to add date and time to 2 seperate cells
> > From: billypat...@sbcglobal.net
> > To: excel-macros@googlegroups.com
>
> >
> > I just got a new job after a years layoff. By trade I'm a unix person
> > but have now entered the microsoft world.
> > I'm currently having to d a lot of work in excel. One thing I
> > consistantly have to do is to put the current time into 1 cell and the
> > date into another cell. This has to be an easy function to do. I've
> > been able to accomplist most of the things I needed to do before, but
> > I'm kind of in a hurry for this.
> > Here's the logic I'm looking at.
> > Have entire column assigned to use this macro.
> > When picking on cell put date or time, depending on column.
> >
> > I will be looking tonight, but would like some assistance.
> >
> > --
> >
> ----------------------------------------------------------------------------------
> > Some important links for excel users:
> > 1. Follow us on TWITTER for tips tricks and links :
> http://twitter.com/exceldailytip
> > 2. Join our Facebook Group @
> http://www.facebook.com/group.php?gid=287779555678
> > 3. Excel tutorials at http://www.excel-macros.blogspot.com
> > 4. Learn VBA Macros at http://www.quickvba.blogspot.com
> > 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
> >
> > To post to this group, send email to excel-macros@googlegroups.com
> >
> > <><><><><><><><><><><><><><><><><><><><><><>
> > HELP US GROW !!
> >
> > We reach over 6,800 subscribers worldwide and receive many nice notes
> about the learning and support from the group.Let friends and co-workers
> know they can subscribe to group at
> http://groups.google.com/group/excel-macros/subscribe
>
> ------------------------------
> Find out now Link all your email accounts and social updates with 
> Hotmail.<http://windowslive.ninemsn.com.au/oneinbox?ocid=T162MSN05A0710G>
>
> --
>
> ----------------------------------------------------------------------------------
> Some important links for excel users:
> 1. Follow us on TWITTER for tips tricks and links :
> http://twitter.com/exceldailytip
> 2. Join our Facebook Group @
> http://www.facebook.com/group.php?gid=287779555678
> 3. Excel tutorials at http://www.excel-macros.blogspot.com
> 4. Learn VBA Macros at http://www.quickvba.blogspot.com
> 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
>
> To post to this group, send email to excel-macros@googlegroups.com
>
> <><><><><><><><><><><><><><><><><><><><><><>
> HELP US GROW !!
>
> We reach over 6,800 subscribers worldwide and receive many nice notes about
> the learning and support from the group.Let friends and co-workers know they
> can subscribe to group at
> http://groups.google.com/group/excel-macros/subscribe
>

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our Facebook Group @ http://www.facebook.com/group.php?gid=287779555678
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 6,800 subscribers worldwide and receive many nice notes about the 
learning and support from the group.Let friends and co-workers know they can 
subscribe to group at http://groups.google.com/group/excel-macros/subscribe

Attachment: ExcelMacros_DateTimeStamp.xlsm
Description: Binary data

Reply via email to