Formula for date to appear on entry of data to cell

sjm44

New Member
Joined
Jul 26, 2011
Messages
13
Hello,

I did try and search for a similar topic but couldn't come across anything, although I'm not even sure I was searching for the right keywords so apologies if I have missed anything.

I am using Windows 7 and Excel 2010.

What I am trying to do is create a form in Excel where when I enter data into a specific cell (B2), the date of which it what entered goes into cell (A2).

I am aware that "ctrl ;" does this but as of yet I have had no success adding this into an IF Function or a macro.

Any help would be much appreciated.

Thanks,

Simon.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Welcome to the board.

You'll need to access excel events to achieve this, specifically the worksheet_change event.

Will you be changing 1 line at a time or are multiple updates possible?

If the former, then you need to right click the sheet tab, choose 'view code' and add the following:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    With Target
        If .Column = 2 Then
            Application.EnableEvents = False
            .Offset(, -1).Value = Now()
            .Offset(, -1).NumberFormat = "dd/mm/yyyy"
            Application.EnableEvents = True
        End If
    End With
End Sub
 
Upvote 0
Welcome to the board.

You'll need to access excel events to achieve this, specifically the worksheet_change event.

Will you be changing 1 line at a time or are multiple updates possible?

If the former, then you need to right click the sheet tab, choose 'view code' and add the following:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    With Target
        If .Column = 2 Then
            Application.EnableEvents = False
            .Offset(, -1).Value = Now()
            .Offset(, -1).NumberFormat = "dd/mm/yyyy"
            Application.EnableEvents = True
        End If
    End With
End Sub
Just what I am looking for. Thanks a lot.

One more thing if possible. How easy is it to file a record in a row by a company name for example into a separate specified sheet?

If it's too much trouble, don't worry. What you've helped me with so far is a big help.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,753
Members
452,940
Latest member
rootytrip

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