Date code problem.

Tartesos

Board Regular
Joined
Feb 3, 2011
Messages
109
I'm using this code in my sheet to get the date in the "L" column if any data is entered in the "B" column cells.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
For Each Cell In Target
With Cell
If .Column = Range("B:B").Column Then
Cells(.Row, "L").Value = Int(Now)
End If
End With
Next Cell
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub

It works fine .... but when it reach the row B:7152 stops adding the date on the "L:7152" when I add any data to the "B" cells on that row and below that row. Can anyone tell me how to change this for happening? Any way I can fix this? , meaby any other code? .. I tried few things but it did not work.

Regards.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Could you not use the following formula in L1?

=if(B1="","",now())

then copy that all the way down to L:x (where x is last row of data)
 
Upvote 0
Not sure the code works for me no matter how many rows.

try this

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
If Intersect(Target, Range("B:B")) Is Nothing Then Exit Sub
If Target.Columns.Count > 1 Then Exit Sub
For Each Cell In Target
Cell.Offset(0, 10).Value = Date
Next Cell
End Sub
 
Upvote 0
Thanks for your tip jamieleeuk but the B cells need to be free of formulas.
dave3009, I have a question about your code. Where it's indicate that the date has to be display on the L column? From the code I can't figure out.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
If Intersect(Target, Range("B:B")) Is Nothing Then Exit Sub
If Target.Columns.Count > 1 Then Exit Sub
For Each Cell In Target
Cell.Offset(0, 10).Value = Date
Next Cell
End Sub

Can you explain a bit ??

Regards,******** type=text/javascript> vbmenu_register("postmenu_2687394", true); *********>
 
Upvote 0
My code will only execute if you are entering data into column B and if the dataset is one column wide. This allows you to enter into many rows in column B but not enter data if you have entered into B&C simulateously for example.

As you will only be entering into column B then column L is 10 columns to the right, hence Offset(0, 10) will get the date entered into it.
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,894
Members
452,948
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