walsh18
08-14-2014, 04:46 AM
This is probably a very basic issue and very issue to solve, but I'm stumped. I have written the following 'If' statements to show a specific userform based on a cells contents. This bit works and the required userform is shown. The code on that userform does not work though - I am very new to this and am probably missing a load of information out that is required.
Please help
If Worksheets("QC History").Range("B3").Value = "XY" Then UserForm4.Show
If Worksheets("QC History").Range("B3").Value = "YZ" Then UserForm5.Show
If Worksheets("QC History").Range("B3").Value = "WX" Then UserForm6.Show
the code on userform that is selected:
Private Sub CommandButton1_Click()
ABC = UserForm4.TextBox1
DEF = UserForm4.TextBox2
T4 = UserForm4.TextBox3
Colour = UserForm4.TextBox4
Worksheets("QC History").Range("AA").Value = Colour
Worksheets("QC History").Range("AG").Value = DEF
Worksheets("QC History").Range("AI").Value = ABC
Worksheets("QC History").Range("AQ").Value = T4
Unload UserForm4
End Sub
I then get a run time error message '1004' Application-defined or object defined error. The above coding works on many other userforms in use for the same worksheet, but on opening the ones from the if statements, it doesn't - what am I missing?
Thanks in advance
Please help
If Worksheets("QC History").Range("B3").Value = "XY" Then UserForm4.Show
If Worksheets("QC History").Range("B3").Value = "YZ" Then UserForm5.Show
If Worksheets("QC History").Range("B3").Value = "WX" Then UserForm6.Show
the code on userform that is selected:
Private Sub CommandButton1_Click()
ABC = UserForm4.TextBox1
DEF = UserForm4.TextBox2
T4 = UserForm4.TextBox3
Colour = UserForm4.TextBox4
Worksheets("QC History").Range("AA").Value = Colour
Worksheets("QC History").Range("AG").Value = DEF
Worksheets("QC History").Range("AI").Value = ABC
Worksheets("QC History").Range("AQ").Value = T4
Unload UserForm4
End Sub
I then get a run time error message '1004' Application-defined or object defined error. The above coding works on many other userforms in use for the same worksheet, but on opening the ones from the if statements, it doesn't - what am I missing?
Thanks in advance