PDA

View Full Version : Worksheet Calculate Question



CloudenL
09-21-2011, 07:27 AM
If in a cell, i have an if statement that will produce blank if the time period is good and "Error" if it is not, and i want a pop up to show if "error" is the result of the If statement, do i use worksheet calculate? or is there some other code i should use or a different way to accomplish this?

Simon Lloyd
09-21-2011, 07:43 AM
What do you mean "Pop up", if the formula equates to "error" then the cell will show just that?

CloudenL
09-21-2011, 11:22 AM
ok, can i make this statement work? i want once dates are filled into D29 and D28 for it to calculate and if it is 365, i want it to do nothing, but if it doesnt (either less or greater) i want a box to pop up with what i have written below. i have been playing with list boxes and can get the list box to show the message, but not sure that is the best choice or how to get the calculation to work to make it show up.

Sub calculate()

If calculate = ("$d$29" - "$d$28") <> 365 Then

Private Sub UserForm_initialize()
Dim prompt As String
ListBox1.AddItem "Time Period of Pricing Contract Invalid."
ListBox1.AddItem ""
ListBox1.AddItem "Please check dates to make sure"
ListBox1.AddItem "they are only for 1 year."
ListBox1.AddItem "If this is to be a multi year agreement"
ListBox1.AddItem "please disucss with your RVP first."

End Sub