PC Review


Reply
Thread Tools Rate Thread

Button on sheet: ? VB code to add date in active cell

 
 
AA Arens
Guest
Posts: n/a
 
      10th Dec 2006
I placed a button on the sheet and would like to know the VB code to
add the present date in the active cell. I did a group search, but not
not find anything.

Bart
Excel 2003

 
Reply With Quote
 
 
 
 
Gord Dibben
Guest
Posts: n/a
 
      10th Dec 2006
Sub NOWDATE()
ActiveCell.Value = Format(Date, "dd-mmm-yy")
End Sub


Gord Dibben MS Excel MVP

On 9 Dec 2006 19:22:34 -0800, "AA Arens" <(E-Mail Removed)> wrote:

>I placed a button on the sheet and would like to know the VB code to
>add the present date in the active cell. I did a group search, but not
>not find anything.
>
>Bart
>Excel 2003


 
Reply With Quote
 
AA Arens
Guest
Posts: n/a
 
      10th Dec 2006
It works, however, I would like to add a range of cells where the
addition is allowed. I am even eble to add a date in a validation
restricted cell.

Bart

On Dec 10, 11:01 am, Gord Dibben <gorddibbATshawDOTca> wrote:
> Sub NOWDATE()
> ActiveCell.Value = Format(Date, "dd-mmm-yy")
> End Sub
>
> Gord Dibben MS Excel MVP
>
> On 9 Dec 2006 19:22:34 -0800, "AAArens" <bartvandon...@gmail.com> wrote:
>
> >I placed a button on the sheet and would like to know the VB code to
> >add the present date in the active cell. I did a group search, but not
> >not find anything.

>
> >Bart
> >Excel 2003


 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      10th Dec 2006
Gord's code puts it in the activecell, so you already have a range of cells.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"AA Arens" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> It works, however, I would like to add a range of cells where the
> addition is allowed. I am even eble to add a date in a validation
> restricted cell.
>
> Bart
>
> On Dec 10, 11:01 am, Gord Dibben <gorddibbATshawDOTca> wrote:
>> Sub NOWDATE()
>> ActiveCell.Value = Format(Date, "dd-mmm-yy")
>> End Sub
>>
>> Gord Dibben MS Excel MVP
>>
>> On 9 Dec 2006 19:22:34 -0800, "AAArens" <bartvandon...@gmail.com> wrote:
>>
>> >I placed a button on the sheet and would like to know the VB code to
>> >add the present date in the active cell. I did a group search, but not
>> >not find anything.

>>
>> >Bart
>> >Excel 2003

>



 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      10th Dec 2006
Bart

Not sure what you're asking for.

Do you want to add the date to multiple cells at a time?

Sub NOWDATE()
With Selection
.Value = Format(Date, "dd-mmm-yy")
End With
End Sub

Prevent adding the date to some cells?

That could be done through Tools>Protection>Protect Sheet


Gord

On 9 Dec 2006 20:40:42 -0800, "AA Arens" <(E-Mail Removed)> wrote:

>It works, however, I would like to add a range of cells where the
>addition is allowed. I am even eble to add a date in a validation
>restricted cell.
>
>Bart
>
>On Dec 10, 11:01 am, Gord Dibben <gorddibbATshawDOTca> wrote:
>> Sub NOWDATE()
>> ActiveCell.Value = Format(Date, "dd-mmm-yy")
>> End Sub
>>
>> Gord Dibben MS Excel MVP
>>
>> On 9 Dec 2006 19:22:34 -0800, "AAArens" <bartvandon...@gmail.com> wrote:
>>
>> >I placed a button on the sheet and would like to know the VB code to
>> >add the present date in the active cell. I did a group search, but not
>> >not find anything.

>>
>> >Bart
>> >Excel 2003


 
Reply With Quote
 
AA Arens
Guest
Posts: n/a
 
      11th Dec 2006
Hi Gord,

I do have a part which is locket and unlocket and I protect the whole
sheet so only a selection of cells are accessable, those who are
unlocked.


I do have the columns (1-4):

Number Date Model Serial#

1 15-05-06 ModelB 5467
2 etc.
3
4
5

All cells below the columns 2,3 and 4 are accessable by the user, but I
want to avoid that a date can be filled in when the active cell is NOT
under the Date column. How to do that?

Bart


On Dec 11, 12:08 am, Gord Dibben <gorddibbATshawDOTca> wrote:
> Bart
>
> Not sure what you're asking for.
>
> Do you want to add the date to multiple cells at a time?
>
> Sub NOWDATE()
> With Selection
> .Value = Format(Date, "dd-mmm-yy")
> End With
> End Sub
>
> Prevent adding the date to some cells?
>
> That could be done through Tools>Protection>Protect Sheet
>
> Gord
>
> On 9 Dec 2006 20:40:42 -0800, "AAArens" <bartvandon...@gmail.com> wrote:
>
> >It works, however, I would like to add a range of cells where the
> >addition is allowed. I am even eble to add a date in a validation
> >restricted cell.

>
> >Bart

>
> >On Dec 10, 11:01 am, Gord Dibben <gorddibbATshawDOTca> wrote:
> >> Sub NOWDATE()
> >> ActiveCell.Value = Format(Date, "dd-mmm-yy")
> >> End Sub

>
> >> Gord Dibben MS Excel MVP

>
> >> On 9 Dec 2006 19:22:34 -0800, "AAArens" <bartvandon...@gmail.com> wrote:

>
> >> >I placed a button on the sheet and would like to know the VB code to
> >> >add the present date in the active cell. I did a group search, but not
> >> >not find anything.

>
> >> >Bart
> >> >Excel 2003


 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      11th Dec 2006
Maybe this one?

Sub NOWDATE()
If ActiveCell.Column = 2 Then
ActiveCell.Value = Format(Date, "dd-mmm-yy")
Else: MsgBox "Dates must be entered in Column B"
Exit Sub
End If
End Sub


Gord

On 11 Dec 2006 05:01:39 -0800, "AA Arens" <(E-Mail Removed)> wrote:

>Hi Gord,
>
>I do have a part which is locket and unlocket and I protect the whole
>sheet so only a selection of cells are accessable, those who are
>unlocked.
>
>
>I do have the columns (1-4):
>
>Number Date Model Serial#
>
>1 15-05-06 ModelB 5467
>2 etc.
>3
>4
>5
>
>All cells below the columns 2,3 and 4 are accessable by the user, but I
>want to avoid that a date can be filled in when the active cell is NOT
>under the Date column. How to do that?
>
>Bart
>
>
>On Dec 11, 12:08 am, Gord Dibben <gorddibbATshawDOTca> wrote:
>> Bart
>>
>> Not sure what you're asking for.
>>
>> Do you want to add the date to multiple cells at a time?
>>
>> Sub NOWDATE()
>> With Selection
>> .Value = Format(Date, "dd-mmm-yy")
>> End With
>> End Sub
>>
>> Prevent adding the date to some cells?
>>
>> That could be done through Tools>Protection>Protect Sheet
>>
>> Gord
>>
>> On 9 Dec 2006 20:40:42 -0800, "AAArens" <bartvandon...@gmail.com> wrote:
>>
>> >It works, however, I would like to add a range of cells where the
>> >addition is allowed. I am even eble to add a date in a validation
>> >restricted cell.

>>
>> >Bart

>>
>> >On Dec 10, 11:01 am, Gord Dibben <gorddibbATshawDOTca> wrote:
>> >> Sub NOWDATE()
>> >> ActiveCell.Value = Format(Date, "dd-mmm-yy")
>> >> End Sub

>>
>> >> Gord Dibben MS Excel MVP

>>
>> >> On 9 Dec 2006 19:22:34 -0800, "AAArens" <bartvandon...@gmail.com> wrote:

>>
>> >> >I placed a button on the sheet and would like to know the VB code to
>> >> >add the present date in the active cell. I did a group search, but not
>> >> >not find anything.

>>
>> >> >Bart
>> >> >Excel 2003


Gord Dibben MS Excel MVP
 
Reply With Quote
 
AA Arens
Guest
Posts: n/a
 
      12th Dec 2006
It works, thank you.

One Q:

On another location the date positioning area is not a column, but a
range Z7 till AC7 instead of Column 2, how to perform?

I tried with the Help section with RANGE , ARRAY but w/o success.


Bart

On Dec 12, 12:43 am, Gord Dibben <gorddibbATshawDOTca> wrote:
> Maybe this one?
>
> Sub NOWDATE()
> If ActiveCell.Column = 2 Then
> ActiveCell.Value = Format(Date, "dd-mmm-yy")
> Else: MsgBox "Dates must be entered in Column B"
> Exit Sub
> End If
> End Sub
>
> Gord
>
> On 11 Dec 2006 05:01:39 -0800, "AAArens" <bartvandon...@gmail.com> wrote:
>
>
>
> >Hi Gord,

>
> >I do have a part which is locket and unlocket and I protect the whole
> >sheet so only a selection of cells are accessable, those who are
> >unlocked.

>
> >I do have the columns (1-4):

>
> >Number Date Model Serial#

>
> >1 15-05-06 ModelB 5467
> >2 etc.
> >3
> >4
> >5

>
> >All cells below the columns 2,3 and 4 are accessable by the user, but I
> >want to avoid that a date can be filled in when the active cell is NOT
> >under the Date column. How to do that?

>
> >Bart

>
> >On Dec 11, 12:08 am, Gord Dibben <gorddibbATshawDOTca> wrote:
> >> Bart

>
> >> Not sure what you're asking for.

>
> >> Do you want to add the date to multiple cells at a time?

>
> >> Sub NOWDATE()
> >> With Selection
> >> .Value = Format(Date, "dd-mmm-yy")
> >> End With
> >> End Sub

>
> >> Prevent adding the date to some cells?

>
> >> That could be done through Tools>Protection>Protect Sheet

>
> >> Gord

>
> >> On 9 Dec 2006 20:40:42 -0800, "AAArens" <bartvandon...@gmail.com> wrote:

>
> >> >It works, however, I would like to add a range of cells where the
> >> >addition is allowed. I am even eble to add a date in a validation
> >> >restricted cell.

>
> >> >Bart

>
> >> >On Dec 10, 11:01 am, Gord Dibben <gorddibbATshawDOTca> wrote:
> >> >> Sub NOWDATE()
> >> >> ActiveCell.Value = Format(Date, "dd-mmm-yy")
> >> >> End Sub

>
> >> >> Gord Dibben MS Excel MVP

>
> >> >> On 9 Dec 2006 19:22:34 -0800, "AAArens" <bartvandon...@gmail.com> wrote:

>
> >> >> >I placed a button on the sheet and would like to know the VB code to
> >> >> >add the present date in the active cell. I did a group search, but not
> >> >> >not find anything.

>
> >> >> >Bart
> >> >> >Excel 2003Gord Dibben MS Excel MVP


 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      12th Dec 2006
Bart

Sub NOWDATE33()
If Not Intersect(ActiveCell, Range("Z7:AC7")) Is Nothing Then
ActiveCell.Value = Format(Date, "dd-mmm-yy")
Else: MsgBox "Dates must be entered in Range(Z7:AC7)"
Exit Sub
End If
End Sub


Gord

On 12 Dec 2006 06:22:16 -0800, "AA Arens" <(E-Mail Removed)> wrote:

>It works, thank you.
>
>One Q:
>
>On another location the date positioning area is not a column, but a
>range Z7 till AC7 instead of Column 2, how to perform?
>
>I tried with the Help section with RANGE , ARRAY but w/o success.
>
>
>Bart
>
>On Dec 12, 12:43 am, Gord Dibben <gorddibbATshawDOTca> wrote:
>> Maybe this one?
>>
>> Sub NOWDATE()
>> If ActiveCell.Column = 2 Then
>> ActiveCell.Value = Format(Date, "dd-mmm-yy")
>> Else: MsgBox "Dates must be entered in Column B"
>> Exit Sub
>> End If
>> End Sub
>>
>> Gord
>>
>> On 11 Dec 2006 05:01:39 -0800, "AAArens" <bartvandon...@gmail.com> wrote:
>>
>>
>>
>> >Hi Gord,

>>
>> >I do have a part which is locket and unlocket and I protect the whole
>> >sheet so only a selection of cells are accessable, those who are
>> >unlocked.

>>
>> >I do have the columns (1-4):

>>
>> >Number Date Model Serial#

>>
>> >1 15-05-06 ModelB 5467
>> >2 etc.
>> >3
>> >4
>> >5

>>
>> >All cells below the columns 2,3 and 4 are accessable by the user, but I
>> >want to avoid that a date can be filled in when the active cell is NOT
>> >under the Date column. How to do that?

>>
>> >Bart

>>
>> >On Dec 11, 12:08 am, Gord Dibben <gorddibbATshawDOTca> wrote:
>> >> Bart

>>
>> >> Not sure what you're asking for.

>>
>> >> Do you want to add the date to multiple cells at a time?

>>
>> >> Sub NOWDATE()
>> >> With Selection
>> >> .Value = Format(Date, "dd-mmm-yy")
>> >> End With
>> >> End Sub

>>
>> >> Prevent adding the date to some cells?

>>
>> >> That could be done through Tools>Protection>Protect Sheet

>>
>> >> Gord

>>
>> >> On 9 Dec 2006 20:40:42 -0800, "AAArens" <bartvandon...@gmail.com> wrote:

>>
>> >> >It works, however, I would like to add a range of cells where the
>> >> >addition is allowed. I am even eble to add a date in a validation
>> >> >restricted cell.

>>
>> >> >Bart

>>
>> >> >On Dec 10, 11:01 am, Gord Dibben <gorddibbATshawDOTca> wrote:
>> >> >> Sub NOWDATE()
>> >> >> ActiveCell.Value = Format(Date, "dd-mmm-yy")
>> >> >> End Sub

>>
>> >> >> Gord Dibben MS Excel MVP

>>
>> >> >> On 9 Dec 2006 19:22:34 -0800, "AAArens" <bartvandon...@gmail.com> wrote:

>>
>> >> >> >I placed a button on the sheet and would like to know the VB code to
>> >> >> >add the present date in the active cell. I did a group search, but not
>> >> >> >not find anything.

>>
>> >> >> >Bart
>> >> >> >Excel 2003Gord Dibben MS Excel MVP


 
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
I need to sort an active sheet using the col of the active cell =?Utf-8?B?SGFtRmx5ZXI=?= Microsoft Excel Programming 3 6th Jun 2006 07:25 PM
Active Cell Copy And Paste Sheet to Sheet =?Utf-8?B?QS5SLkogQWxsYW4gSmVmZmVyeXM=?= Microsoft Excel New Users 4 4th May 2006 02:04 AM
How do i copy a active sheet to a new sheet with code and everything Karill Microsoft Excel Programming 2 11th Apr 2006 06:22 PM
Copy from active sheet and paste into new sheet using info from cell in active Ingve Microsoft Excel Programming 3 23rd Jan 2006 09:57 PM
Adding a control button to insert a date in the active cell. =?Utf-8?B?TWlrZQ==?= Microsoft Excel Misc 2 15th Feb 2005 06:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:46 PM.