If Date add 5 days

seacrest

Active Member
Joined
Aug 15, 2002
Messages
301
I need a macro that will run down column B and add 5 days to an existing date
If empty do nothing
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Try...

Code:
Sub AddtoDate()
    Dim LR As Long
    Dim i As Long
    LR = Range("B" & Rows.Count).End(xlUp).Row
    For i = 1 To LR
        If Range("B" & i) <> "" Then
            Range("B" & i).Value = Range("B" & i) + 5
        End If
    Next i
End Sub
 
Upvote 0
This foolow code should make the changes requested to worksheets(1)

Code:
Sub add5days()
    Dim RowNo As Long
    For RowNo = 2 To ThisWorkbook.Worksheets(1).UsedRange.Rows.Count
        If IsEmpty(Cells(RowNo, 2)) Then
            'do nothing
        Else
            Cells(RowNo, 2) = Cells(RowNo, 2) + 5
        End If
    Next RowNo
End Sub
 
Upvote 0
I think Jeffery is offline ATM
Is the add offset, instead of the code Jeffrey has given you, or an extra to the code ?
Code:
 If Range("B" & i) <> "" AND range("B" & i).Offset(,1) ="Overdue" Then
or
Code:
 If Range("B" & i) .offset(,1) = "Overdue" Then
 
Upvote 0

Forum statistics

Threads
1,222,143
Messages
6,164,178
Members
451,880
Latest member
2da

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