Refining date macro to only perform when 4 cells have values in them

Laurence D

New Member
Joined
Sep 14, 2016
Messages
31
Hi,

I am wanting some help to refine this date private sub code. Could somebody please help me include another step so that this sub will only perform if the range in I:L has got data in the cells. Currently it will perform if I put data in the L column. It needs to be similar to an AND approach (i.e. if any of the four cells are empty then exit sub etc.).

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Target.Cells.Count > 1 Then Exit Sub
    
    Dim A As Range, Inte As Range, r As Range
    Set A = Range("L:L")
    Set Inte = Intersect(A, Target)
    If Inte Is Nothing Then Exit Sub
    Application.EnableEvents = False
        For Each r In Inte
            If Inte Is Nothing Then
            Exit Sub
            End If
            If r.Offset(0, 1).Value = "" Then
               r.Offset(0, 1).Value = Date
            End If
            Next r
        Application.EnableEvents = True
End Sub

Thanks Laurence
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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