Jump to content


Photo

Autodate On Excel Vb Field


  • Please log in to reply
5 replies to this topic

#1 Rossco

Rossco
  • Member
  • 279 posts

Posted 01 June 2012 - 02:30 PM

Hi in my current role I am required to keep a spreadsheet with all of the tickets I have worked on for a specific date.

I have managed to create a userform in excel & have managed to set one of the fields to include a value that never changes (account name)

What I am having problems with is setting the field up in VB to insert the current date.

Can anyone advise of code to use for this please as it has been driving me nuts & time wasted on google with no success.

I can post the code in here if needed
Oppose team GB sign the petition.
http://new.petitiono...2/petition.html

#2 OLAS

OLAS
  • Member
  • 6,028 posts

Posted 19 June 2012 - 12:15 AM

Used to be a wizz on VBA but that was a good 10 years ago.

Dim dv As Date
dv = DateValue(Now)

Then apply that to the field you need the first time.

If you are updating, copy the field data and re-apply instead of updating with a new date. There are better ways to do this but I've had a few bevies.

I may be 100% off track though...

#3 OLAS

OLAS
  • Member
  • 6,028 posts

Posted 19 June 2012 - 12:17 AM

Seems like I have.

The VB code will work for inserting the current date. You may need to change the locale to get a UK date as the default is normally US.

#4 andymac

andymac
  • Member
  • 3,753 posts

Posted 19 June 2012 - 12:23 AM

Wait a minute 01.17 here time and you are sober?


You, the lovechild of Pistonbroke?
Life was easier when I didn't have a clue....

#5 OLAS

OLAS
  • Member
  • 6,028 posts

Posted 19 June 2012 - 04:07 PM

Who said I was sober! I wasn't long in from the pub :beer2:

#6 joecraigfanclub

joecraigfanclub
  • Member
  • 1,460 posts

Posted 03 July 2012 - 08:54 PM

If the field is a cell does it have to be in VB?
He perfectly encapsulates that mixture of dourness and hope which characterises the committed Scotland fan.