Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MPB MPB is offline
external usenet poster
 
Posts: 1
Default today code in vba

Good evening all

I am after some simple code to apply to a CommandButton1_Click(),
where when the button is clicked, today's date is inserted into the active cell.
(Though I do require this date to then be fixed, and not change the following day)

Any help most appreciated.
Thank you
Mathew




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date: 11/12/2003
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default today code in vba

Mathew,

Private Sub CommandButton1_Click()
Worksheets("yoursheetname").Range("A1") = Now
End Sub

You can replace the "Now" with something like:
Format(Now, "m/d/yy")
or whatever format you'd like it to appear in.

By the way..."Today" can't be used in VBA

John

"MPB" wrote in message
...
Good evening all

I am after some simple code to apply to a CommandButton1_Click(),
where when the button is clicked, today's date is inserted into the active

cell.
(Though I do require this date to then be fixed, and not change the

following day)

Any help most appreciated.
Thank you
Mathew




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date: 11/12/2003



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default today code in vba

Mathew,

You've already had 2 responses in the .misc group.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"MPB" wrote in message
...
Good evening all

I am after some simple code to apply to a CommandButton1_Click(),
where when the button is clicked, today's date is inserted into the active

cell.
(Though I do require this date to then be fixed, and not change the

following day)

Any help most appreciated.
Thank you
Mathew




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date: 11/12/2003



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default today code in vba

I'd think

Worksheets("yoursheetname").Range("A1").Value = Date

would be more appropriate than using Now, or perhaps

With Worksheets("yoursheetname").Range("A1")
.NumberFormat = "m/d/yy"
.Value = Date
End With

In article ,
"John Wilson" wrote:

Mathew,

Private Sub CommandButton1_Click()
Worksheets("yoursheetname").Range("A1") = Now
End Sub

You can replace the "Now" with something like:
Format(Now, "m/d/yy")
or whatever format you'd like it to appear in.

By the way..."Today" can't be used in VBA

John

"MPB" wrote in message
...
Good evening all

I am after some simple code to apply to a CommandButton1_Click(),
where when the button is clicked, today's date is inserted into the active

cell.
(Though I do require this date to then be fixed, and not change the

following day)

Any help most appreciated.
Thank you
Mathew




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date: 11/12/2003



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default today code in vba

on the button event put
activecell.value = Date

that will do it. you can format it anyway you like.

Keith
www.kjtfs.com
-----Original Message-----
Good evening all

I am after some simple code to apply to a

CommandButton1_Click(),
where when the button is clicked, today's date is

inserted into the active cell.
(Though I do require this date to then be fixed, and not

change the following day)

Any help most appreciated.
Thank you
Mathew




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date:

11/12/2003
.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default today code in vba

You don't need a macro.

Control ; does the job for jou.

Gerrit


"Keith" schreef in bericht
...
on the button event put
activecell.value = Date

that will do it. you can format it anyway you like.

Keith
www.kjtfs.com
-----Original Message-----
Good evening all

I am after some simple code to apply to a

CommandButton1_Click(),
where when the button is clicked, today's date is

inserted into the active cell.
(Though I do require this date to then be fixed, and not

change the following day)

Any help most appreciated.
Thank you
Mathew




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date:

11/12/2003
.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default today code in vba


"MPB" schreef in bericht
...
Good evening all

I am after some simple code to apply to a CommandButton1_Click(),
where when the button is clicked, today's date is inserted into the active

cell.
(Though I do require this date to then be fixed, and not change the

following day)

Any help most appreciated.
Thank you
Mathew


type:

Control ; in a cel, jou have a fixed date


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default today code in vba

J.E.

Got into the habit of just using "Now" and just formatting it the way
I want to see it. Old habits are hard to break.
"Date" would be a lot easier if that's all someone needed.

John

"J.E. McGimpsey" wrote in message
...
I'd think

Worksheets("yoursheetname").Range("A1").Value = Date

would be more appropriate than using Now, or perhaps

With Worksheets("yoursheetname").Range("A1")
.NumberFormat = "m/d/yy"
.Value = Date
End With

In article ,
"John Wilson" wrote:

Mathew,

Private Sub CommandButton1_Click()
Worksheets("yoursheetname").Range("A1") = Now
End Sub

You can replace the "Now" with something like:
Format(Now, "m/d/yy")
or whatever format you'd like it to appear in.

By the way..."Today" can't be used in VBA

John

"MPB" wrote in message
...
Good evening all

I am after some simple code to apply to a CommandButton1_Click(),
where when the button is clicked, today's date is inserted into the

active
cell.
(Though I do require this date to then be fixed, and not change the

following day)

Any help most appreciated.
Thank you
Mathew




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date: 11/12/2003





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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
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


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