blounty
Technical User
- Mar 23, 2006
- 46
Hey guys,
I have created a function to take information from a form and enter into a sheet, then give message box's based on this information. The code below works fine and i am happy with but i have to do this with another form which has about 20 or more text box's is there an easier way of doing this that will reduce the code?
Any ideas would be great...
Thanks for looking and merry xmas. :->
I have created a function to take information from a form and enter into a sheet, then give message box's based on this information. The code below works fine and i am happy with but i have to do this with another form which has about 20 or more text box's is there an easier way of doing this that will reduce the code?
Code:
Private Sub CommandButton1_Click()
Dim Count As Long
Dim Make As String
Dim Model As String
Dim Rental As String
Dim Mvol As String
Dim Mcpp As String
Dim Cvol As String
Dim Ccpp As String
Count = Worksheets("Proposal").Range("M3").Value
Make = "N" & Count
Model = "O" & Count
Rental = "P" & Count
Mvol = "Q" & Count
Mcpp = "R" & Count
Cvol = "S" & Count
Ccpp = "T" & Count
If UserForm5.TextBox1.Value = "" Or UserForm5.TextBox2.Value = "" Or UserForm5.TextBox3.Value = "" Or UserForm5.TextBox4.Value = "" Or UserForm5.TextBox5.Value = "" Or UserForm5.TextBox6.Value = "" Or UserForm5.TextBox7.Value = "" Then
MsgBox "Please Enter Values For All Items", vbExclamation, "ERROR"
Else
Worksheets("Proposal").Range(Make).Value = UserForm5.TextBox1.Value
Worksheets("Proposal").Range(Model).Value = UserForm5.TextBox2.Value
Worksheets("Proposal").Range(Rental).Value = UserForm5.TextBox3.Value
Worksheets("Proposal").Range(Mvol).Value = UserForm5.TextBox4.Value
Worksheets("Proposal").Range(Mcpp).Value = UserForm5.TextBox5.Value
Worksheets("Proposal").Range(Cvol).Value = UserForm5.TextBox6.Value
Worksheets("Proposal").Range(Ccpp).Value = UserForm5.TextBox7.Value
If Worksheets("Proposal").Range("AA2").Value > Worksheets("Proposal").Range("AC2").Value Then
MsgBox "New Device Mix Mono Volume Is Less Than Current Device Mix, Please Add More Devices", vbInformation
End If
If Worksheets("Proposal").Range("AA2").Value <= Worksheets("Proposal").Range("AC2").Value Then
MsgBox "New Device Mix Mono Volume Is Now Sufficient", vbInformation
End If
If Worksheets("Proposal").Range("AB2").Value > Worksheets("Proposal").Range("AD2").Value Then
MsgBox "New Device Mix Colour Volume Is Less Than Current Device Mix, Please Add More Devices", vbInformation
End If
If Worksheets("Proposal").Range("AB2").Value <= Worksheets("Proposal").Range("AD2").Value Then
MsgBox "New Device Mix Colour Volume Is Now Sufficient", vbInformation
End If
If Worksheets("Proposal").Range("AE2").Value <= Worksheets("Proposal").Range("AF2").Value Then
MsgBox "New Device Mix Volume Is Now Sufficient, Please Go To Next Stage", vbInformation
End If
UserForm5.ComboBox1.Text = ""
UserForm5.Frame1.Visible = False
End If
End Sub
Any ideas would be great...
Thanks for looking and merry xmas. :->