PDA

View Full Version : Conditional macros



Edi
06-22-2011, 12:45 AM
Hi,

It's my first day at using VBA and would be great if someone can help me with the attached spreadsheet. There's a few things I'd like to do:
a) If this is a new test (F2 = "Y") then:
- the duration (H14) = 1 otherwise (ie if F2 = "N") it can be any number from 1-10.
- the start date must be 12 months from the registration date ie H12 = H10 + 12 months, otherwise the registration date (H12) can be any date which is not more than 12 months away from H10

b) I've built in a macro so that if the user toggles with F2, cells F4 and F6 will clear. Is it possible to create a pop up box which warns the user that certain fields will now be cleared?

Thanks for the help!

Bob Phillips
06-22-2011, 03:24 AM
You don't need VBA. You have used Data Validation for the first, and you can do similar with the second, using Custom and a formula of

=IF(A1_test="Y",A2_start_date=DATE(YEAR(A2_initial_date)+1,MONTH(A2_initial_date),DAY(A2_i nitial_date)),AND(A2_start_date>=A2_initial_date,A2_start_date<=DATE(YEAR(A2_initial_date)+1,MONTH(A2_initial_date),DAY(A2_initial_date))) )

Edi
06-26-2011, 07:34 PM
Thanks, that was helpful