adding a formula to VBA code

James__S

Active Member
Joined
Jan 26, 2014
Messages
332
I have the following code which works plus a formula in cell range G5:G123....how do i add the the formula to the VBA code please

Formula =IF(F5<>"".F5< today () +3 )<today()+3)


Code:
Private Sub Workbook_Open()
For Each cell In Range("F5:F19")
If cell.Value < Date + 3 And cell.Value <> "" Then
cell.Interior.Color = 3
cell.Font.ColorIndex = 2
cell.Font.Bold = True
End If
Next
End Sub

<today(),"send reminder","")
<today()+3)
<today(),"send reminder","")
<today()+3)<today()+3)
<today()+3)

Also instead of having the code update when book opens could it have a Commandbutton so it can be updated anytime

Thanks</today()+3)
</today()+3)<today()+3)
</today(),"send></today()+3)
</today(),"send></today()+3)
 
Last edited:
<today() +3,"send="" notice","")<today()="" reminder","")

Sorry i sent wrong formula <today() +3,"send="" notice","")
=IF(F5 < TODAY() +3,"Send Notice","")
<today() +3,"send="" notice","")

<today()+3,"send notice","")<today()="" +3,"="" send="" notice","")<="" today()=""></today()+3,"send></today()></today()></today()>
 
Last edited:
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try,

Private Sub Data_Format_Formulas()
For Each cell In Range("F5:F19")
If cell.Value < Date + 3 And cell.Value <> "" Then
cell.Interior.Color = 3
cell.Font.ColorIndex = 2
cell.Font.Bold = True
End If
Next
Range("G5:G123").Formula = "=IF(F5 < TODAY()+3,""Send Notice"","""")"
End Sub
 
Upvote 0
Sorry, it should be be just Sub Data_Format_Formulas() Please remove Private
 
Upvote 0
No more errors but it places the Send Notice down the column even when there is no date in F5:F123
 
Upvote 0
I should practice what I preach, sorry:

Code:
Range("G5:G123").Formula = "=IF(AND(ISNUMBER(F5),F5 < TODAY()+3),""Send Notice"","""")"
 
Upvote 0
What is the best way to add the code to a Active-X control button

Excellent and thanks to you both for your help..appreciated
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,130
Messages
6,129,062
Members
449,484
Latest member
khairianr

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