Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have a worksheet with five checkboxes and text boxes. If a checkbox is checked, data should be entered in the corresponding text box. I'd like an input box (or some other form of validation - open to suggestions) to pop up if the checkbox is checked and the text box is empty. I figured the easiest way is to put the code in the Thisworkbook module, beforesave, and I can get it to work using multiple nested If statements, but there has to be an easier way! Otherwise I'll end up with a mile of code that's hard to navigate. Is there some loop I could use? A sample of the code I'm working with now is below, thank you so much for your help! Check boxes and corresponding text boxes a -SurfaceCheck6 and SurfaceSoilTextbox -SubSurfaceCheck3 and SubSurfaceSoilTextbox -GroundwaterCheck5 and GroundwaterTextbox -SurfaceWaterCheck4 and SurfaceWaterTextbox -SedimentCheck3 and SedimentTextbox If Worksheets("human health csm").Visible = True Then Worksheets("human health csm").Select With ActiveSheet 'Checks if the "Other" checkbox is checked/unchecked for Surface Soils If .SurfaceCheck6.Value = True And .SurfaceSoilTextbox.Text = "" Then 'value if true .SurfaceSoilTextbox.Activate .SurfaceSoilTextbox.Value = Application.InputBox("Please enter a transport mechanism for the Surface Soil section.", "Please enter a transport mechanism.") If .SurfaceSoilTextbox.Value = "FALSE" Then .SurfaceSoilTextbox.Value = "" End If 'checks if the "Other" checkbox is checked/unchecked for Subsurface soils and cancels if necessary. If .SubSurfaceCheck3.Value = True And .SubsurfaceSoilTextbox.Text = "" Then .SubsurfaceSoilTextbox.Activate .SubsurfaceSoilTextbox.Value = Application.InputBox("Please enter a transport mechanism for the Subsurface Soil section.", "Please enter a transport mechanism.") If .SubsurfaceSoilTextbox.Value = "FALSE" Then .SubsurfaceSoilTextbox.Value = "" End If End If End If End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Nested IF statements | Excel Discussion (Misc queries) | |||
Nested If Statements | Excel Worksheet Functions | |||
Nested if statements | Excel Worksheet Functions | |||
Nested if statements | Excel Worksheet Functions | |||
Nested If statements | Excel Worksheet Functions |