Insert Dates automatically

maxlm

Board Regular
Joined
Jul 22, 2003
Messages
112
I need to be able to put dates automatically on VBA for cells using offset shown below. The sample is only for one column. How do I add the other for j, k, l, m, n using the following offsets. PLESAE HELP... THANKS.
Offsets:
j = 11
k = 1
l = 30
m = 4
n = 1

Private Sub Worksheet_Change(ByVal Target As Range)
Dim I, j, k, l, m, n As Range
Set I = Intersect(Range("BC4:BC500"), Target)
Set j = Intersect(Range("AT4:AT500"), Target)
Set k = Intersect(Range("AD4:AD500"), Target)
Set l = Intersect(Range("AN4:AN500"), Target)
Set m = Intersect(Range("AL4:AL500"), Target)
Set n = Intersect(Range("AP4:AP500"), Target)

If I Is Nothing Then Exit Sub
Application.EnableEvents = False
Dim c As Range
For Each c In I
c.Offset(0, 1).Value = Format(Now, "mm/dd/yy")
Next c
Application.EnableEvents = True

End Sub
 
Try the following:

<font face=Courier New><SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Sub</SPAN> Worksheet_Change(<SPAN style="color:darkblue">ByVal</SPAN> Target <SPAN style="color:darkblue">As</SPAN> Range)
<SPAN style="color:darkblue">If</SPAN> Intersect(Target(1, 1), Range("AT:AT,AV:AV,BE:BE,BL:BL")) <SPAN style="color:darkblue">Is</SPAN> Nothing _
    <SPAN style="color:darkblue">Then</SPAN> <SPAN style="color:darkblue">Exit</SPAN> <SPAN style="color:darkblue">Sub</SPAN>
Application.EnableEvents = <SPAN style="color:darkblue">False</SPAN>
<SPAN style="color:darkblue">If</SPAN> <SPAN style="color:darkblue">Not</SPAN> Intersect(Target(1, 1), Range("AT:AT,BL:BL")) <SPAN style="color:darkblue">Is</SPAN> <SPAN style="color:darkblue">Nothing</SPAN> Then _
    Cells(Target(1, 1).Row, 13).Value = Environ("UserName")
<SPAN style="color:darkblue">With</SPAN> Target(1, 1)
    Cells(.Row, WorksheetFunction.Lookup(.Column, _
        [{46,12;48,59;57,58;64,12}])).Value = <SPAN style="color:darkblue">Date</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">With</SPAN>
Application.EnableEvents = <SPAN style="color:darkblue">True</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN>
</FONT>
 
Upvote 0

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

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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