Date stamp + text macro needed

TeppE

New Member
Joined
May 19, 2011
Messages
7
Dear MrExcel

I need a excel macro that inputs text and date for me.

eks: ok 23.05.2011 or dead 23.05.2011

we want excel to fill in the rest of the text after we have written ok or dead.


please help

kind regards

bellowed fan
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
This is fir values entered in column A (1): right click the sheet tab, select View Code and paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Column = 1 Then
    Application.EnableEvents = False
    Target.Value = Target.Value & " " & Format(Date, "dd.mm.yyyy")
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0
First of, thanks a bunch <3

second: how did you build up the macro, where does it say ok and dead?

third: how do i change column from A?

kind regards

bellowed fan
 
Upvote 0
I didn't realise it had to be those specific words. Try

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Column = 1 Then
    Application.EnableEvents = False
    If Target.Value = "ok" Or Target.Value = "dead" Then Target.Value = Target.Value & " " & Format(Date, "dd.mm.yyyy")
    Application.EnableEvents = True
End If
End Sub

Change 1 to the number of the column.
 
Upvote 0
I diden't quite understand the macro, do i change 1 to say 7 so it ends up in column G or do i write G in the macro. neither did work

thanks so far

kind regards
 
Upvote 0
For column G and a case-insensitive comparison try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Column = 7 Then
    Application.EnableEvents = False
    If LCase(Target.Value) = "ok" Or LCase(Target.Value) = "dead" Then Target.Value = Target.Value & " " & Format(Date, "dd.mm.yyyy")
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top