Attaching data to other data

Rivermark

New Member
Joined
Jan 27, 2011
Messages
16
I have a list of clients, which changes quite often. Every month I have to do an invoice which includes those clients, some clients have been there for several months and some only several days.

I would like an entry date to be attached to the specific person, so when I create the invoice and add their name, the corresponding entry date column automatically fills in with their date of entry.

I'm sure there is information that you need me to be more specific on, but not sure where to start.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi Rivermark,

You can do that with worksheet_change event code.

Let's assume you want to enter your client names in Col B and have today's date automatically entered into Col A. So the end result looks something like this...

Excel Workbook
AB
1Entry DateClient Name
27/19/2011ABC Company
37/19/2011XYZ Inc
Sheet1


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code).

1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
2. Select the worksheet in which your code is to run
3. Right click on the sheet tab and choose View Code, to open the Visual Basic Editor
4. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
5. Press the keys ALT + Q to exit the Editor, and return to Excel

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    On Error GoTo CleanUp
    If Not Intersect(Target, Range("B:B")) Is Nothing Then
        If Target.Row = 1 Then Exit Sub 'Header row
        Application.EnableEvents = False
        If Len(Target) > 0 Then Target.Offset(0, -1).Value = Date
    End If
CleanUp:
    Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,608
Messages
6,179,872
Members
452,949
Latest member
Dupuhini

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