Hi,
How to shorten this code. I have 35 ABT's to copy this same function.I am still at ABT 4, but it seems to me that the code is already long and huge. Is there any way the code can be shorten?
How to shorten this code. I have 35 ABT's to copy this same function.I am still at ABT 4, but it seems to me that the code is already long and huge. Is there any way the code can be shorten?
Code:
Private Sub CommandButton1_Click()
If ABT1.BackColor = vbGreen Then
Worksheets("Plan").Range("C3").Value = Label7.Caption
Worksheets("Plan").Range("D3").Value = Label9.Caption
Worksheets("Plan").Range("E3").Value = TextBox3.Value
Else
Worksheets("Plan").Range("E3").Value = "No Ullage"
End If
If ABT2.BackColor = vbGreen Then
Worksheets("Plan").Range("C4").Value = Label10.Caption
Worksheets("Plan").Range("D4").Value = Label12.Caption
Worksheets("Plan").Range("E4").Value = TextBox4.Value
Else
Worksheets("Plan").Range("E4").Value = "No Ullage"
End If
If ABT3.BackColor = vbGreen Then
Worksheets("Plan").Range("C5").Value = Label13.Caption
Worksheets("Plan").Range("D5").Value = Label15.Caption
Worksheets("Plan").Range("E5").Value = TextBox7.Value
Else
Worksheets("Plan").Range("E5").Value = "No Ullage"
End If
If ABT4.BackColor = vbGreen Then
Worksheets("Plan").Range("C6").Value = Label16.Caption
Worksheets("Plan").Range("D6").Value = Label18.Caption
Worksheets("Plan").Range("E6").Value = TextBox10.Value
Else
Worksheets("Plan").Range("E6").Value = "No Ullage"
End If
If ABT4.BackColor = vbGreen Then
Worksheets("Plan").Range("C7").Value = Label19.Caption
Worksheets("Plan").Range("D7").Value = Label21.Caption
Worksheets("Plan").Range("E7").Value = TextBox13.Value
Else
Worksheets("Plan").Range("E7").Value = "No Ullage"
End If
End Sub