How to add days to a column of date and execute result on the next column

fahadun

New Member
Joined
Jul 27, 2017
Messages
22
Hello,

I have two columns column a and column b.
column a has alot of dates in it also some empty cells
What i want to do is add 30 days to those dates and publish the result on column b.
and when the cells are blank then it will be blank.
This is my code, but showing an error, type mismatch. how to solve it with a better code?

Code:
Sub DateExample()
Application.ScreenUpdating = False
Range("A4:A100000").Copy Destination:=Range("B4:B99999")
Dim rng As Range
    For Each rng In Range("B4:B99999").Cells
      rng.Value = rng.Value + 30
    Next rng
    
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
How about
Code:
Sub Plus30()
   With Range("A4", Range("A" & Rows.Count).End(xlUp)).SpecialCells(xlConstants)
      .Offset(, 1).FormulaR1C1 = "=rc[-1]+30"
      .Offset(, 1).Value = .Offset(, 1).Value
   End With
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0
Like this
Code:
Sub Plus30()
   With Range("A4", Range("A" & Rows.Count).End(xlUp)).SpecialCells(xlConstants)
      .Offset(, 23).FormulaR1C1 = "=rc1+30"
      .Offset(, 23).Value = .Offset(, 23).Value
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,315
Members
452,634
Latest member
cpostell

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