trying to write a very simple subroutine and having a hard time

EmeraldEngineer

New Member
Joined
May 7, 2014
Messages
7
I'm attempting to write a simple subroutine to determine whether or not cel (E4) has a date in it and if it does then populate cell (F4) with that date plus 14 days and cell (G4) with that date plus 28 days. I would also like the sub to run once the date is entered in cell( E4). Look below to see what I've attempted so far and try to hold back your chuckling ha. I'm obviously not very experienced with vba but would really appreciate it if someone could help me out. Thanks.

Private Sub Natalie()
Dim Number_1 As Integer
Dim Number_2 As Integer

Number_1 = 14
Number_2 = 28

If Worksheets("Reports 1-3").Range("F4").Value Then
Worksheets("Reports 1-3").Range("F4").Value = ""
Worksheets("Reports 1-3").Range("G4").Value = ""
Else
Worksheets("Reports 1-3").Range(F4).Value = Worksheets("Reports 1-3").Range(E4).Value + Number_1
Worksheets("Reports 1-3").Range(G4).Value = Worksheets("Reports 1-3").Range(E4).Value + Number_2
End If
End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try replacing:

Code:
If Worksheets("Reports 1-3").Range("F4").Value Then

with:

Code:
If Worksheets("Reports 1-3").Range("E4").Value = "" Then
 
Upvote 0
Oh great! That did it! Thank you! Now all i need to do is figure out how to make it run when the value of cell E4 is changed.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

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