PC Review


Reply
Thread Tools Rate Thread

Auto fill today's date

 
 
=?Utf-8?B?bmFiYW5jbw==?=
Guest
Posts: n/a
 
      28th Jul 2007
Hello,

How would I alter the below to put today's date in column A if a word is
entered into column B? For example, when "tower" is typed into B16, A16
automatically puts todays date in 07/07/07 format?

Thanks for your help
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlrZSBI?=
Guest
Posts: n/a
 
      28th Jul 2007
Hi,

Right click the sheet tab, view code and paste this in.

Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If .Count > 1 Then Exit Sub
If Not Intersect(Range("B1:B16"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
.Offset(0, 1).ClearContents
Else
With .Offset(0, -1)
.NumberFormat = "dd mm yy"
.Value = Now
End With
End If
Application.EnableEvents = True
End If
End With
End Sub

Mike

"nabanco" wrote:

> Hello,
>
> How would I alter the below to put today's date in column A if a word is
> entered into column B? For example, when "tower" is typed into B16, A16
> automatically puts todays date in 07/07/07 format?
>
> Thanks for your help

 
Reply With Quote
 
=?Utf-8?B?bmFiYW5jbw==?=
Guest
Posts: n/a
 
      28th Jul 2007
Mike, is there a way to delete the date in the event there is nothing in
column B?

"Mike H" wrote:

> Hi,
>
> Right click the sheet tab, view code and paste this in.
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> With Target
> If .Count > 1 Then Exit Sub
> If Not Intersect(Range("B1:B16"), .Cells) Is Nothing Then
> Application.EnableEvents = False
> If IsEmpty(.Value) Then
> .Offset(0, 1).ClearContents
> Else
> With .Offset(0, -1)
> .NumberFormat = "dd mm yy"
> .Value = Now
> End With
> End If
> Application.EnableEvents = True
> End If
> End With
> End Sub
>
> Mike
>
> "nabanco" wrote:
>
> > Hello,
> >
> > How would I alter the below to put today's date in column A if a word is
> > entered into column B? For example, when "tower" is typed into B16, A16
> > automatically puts todays date in 07/07/07 format?
> >
> > Thanks for your help

 
Reply With Quote
 
=?Utf-8?B?TWlrZSBI?=
Guest
Posts: n/a
 
      28th Jul 2007
Hi,

You confused me a bit there because that was what it was supposed to do
until I spotted a typo.

Change this line
Offset(0, 1).ClearContents

to this
Offset(0, -1).ClearContents

Mike




"nabanco" wrote:

> Mike, is there a way to delete the date in the event there is nothing in
> column B?
>
> "Mike H" wrote:
>
> > Hi,
> >
> > Right click the sheet tab, view code and paste this in.
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > With Target
> > If .Count > 1 Then Exit Sub
> > If Not Intersect(Range("B1:B16"), .Cells) Is Nothing Then
> > Application.EnableEvents = False
> > If IsEmpty(.Value) Then
> > .Offset(0, 1).ClearContents
> > Else
> > With .Offset(0, -1)
> > .NumberFormat = "dd mm yy"
> > .Value = Now
> > End With
> > End If
> > Application.EnableEvents = True
> > End If
> > End With
> > End Sub
> >
> > Mike
> >
> > "nabanco" wrote:
> >
> > > Hello,
> > >
> > > How would I alter the below to put today's date in column A if a word is
> > > entered into column B? For example, when "tower" is typed into B16, A16
> > > automatically puts todays date in 07/07/07 format?
> > >
> > > Thanks for your help

 
Reply With Quote
 
Bruise
Guest
Posts: n/a
 
      1st Aug 2007
Hi Mike.

I've used your code and it's giving me some problems. Hope you don't mind
me asking for your help.

When I run the 'auto date' code, it cancels out the vlookup code and creates
and error. After this happens, all the code in my workbook becomes
inoperable. Can you examine the code I'm using and give me some hints,
please?
---
Private Sub Worksheet_Change(ByVal Target As Range)
<<<<<<The following code runs the vlookup...>>>>>>
Dim rng As Range, res As Variant

If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("B6:B5000")) Is Nothing Then Exit Sub

Set rng = Worksheets("StatePris").Range("A1:C50000")

res = Application.VLookup(Target, rng, 2, False)

Application.EnableEvents = False
If IsError(res) Then
Target.Offset(0, 1).Resize(1, 2).Value = ""
Else
Target.Offset(0, 1).Value = res
Target.Offset(0, 2).Value = Application.VLookup(Target, rng, 3, False)
Application.EnableEvents = True
End If

<<<<this code runs the auto date>>>>
With Target
With Target
If .Count > 1 Then Exit Sub
If Not Intersect(Range("B6:B2000"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
.Offset(0, -1).ClearContents
Else
With .Offset(0, -1)
.NumberFormat = "dd mm yy"
.Value = Now
End With
End If
Application.EnableEvents = True
End If
End With
End Sub


Thanks....
Mark


"Mike H" <(E-Mail Removed)> wrote in message
news:7566AEEE-E5E7-4E0F-A8F4-(E-Mail Removed)...
> Hi,
>
> You confused me a bit there because that was what it was supposed to do
> until I spotted a typo.
>
> Change this line
> Offset(0, 1).ClearContents
>
> to this
> Offset(0, -1).ClearContents
>
> Mike
>
>
>
>
> "nabanco" wrote:
>
>> Mike, is there a way to delete the date in the event there is nothing in
>> column B?
>>
>> "Mike H" wrote:
>>
>> > Hi,
>> >
>> > Right click the sheet tab, view code and paste this in.
>> >
>> > Private Sub Worksheet_Change(ByVal Target As Range)
>> > With Target
>> > If .Count > 1 Then Exit Sub
>> > If Not Intersect(Range("B1:B16"), .Cells) Is Nothing Then
>> > Application.EnableEvents = False
>> > If IsEmpty(.Value) Then
>> > .Offset(0, 1).ClearContents
>> > Else
>> > With .Offset(0, -1)
>> > .NumberFormat = "dd mm yy"
>> > .Value = Now
>> > End With
>> > End If
>> > Application.EnableEvents = True
>> > End If
>> > End With
>> > End Sub
>> >
>> > Mike
>> >
>> > "nabanco" wrote:
>> >
>> > > Hello,
>> > >
>> > > How would I alter the below to put today's date in column A if a word
>> > > is
>> > > entered into column B? For example, when "tower" is typed into B16,
>> > > A16
>> > > automatically puts todays date in 07/07/07 format?
>> > >
>> > > Thanks for your help



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto fill today's date when checkbox checked Sunflower Microsoft Access Forms 2 17th Jun 2009 11:44 AM
Enter Start Date and Auto Fill the End Date =?Utf-8?B?SmV0?= Microsoft Access Queries 3 16th Apr 2007 08:52 PM
how do I program a cell to automatically fill in today;s date? =?Utf-8?B?YWxsYW5sZXZ5NzM0Mg==?= Microsoft Excel Worksheet Functions 1 12th Sep 2006 03:24 PM
Fill cell with today's date =?Utf-8?B?U2FyYWhia2VsbHk=?= Microsoft Excel Misc 6 20th Jan 2006 01:16 AM
Date created field (auto current date fill-in) Lauri Microsoft Access Forms 3 13th Jul 2004 08:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:04 PM.