Hello to all in the forum, I am sorry if this question has already been asked but I'm new to the forum and don't know how to search.
I have 20 different userforms that I use to output different data but the userforms have some commonality such as information relating to customers.
I find that it's better to call the code from a module that repeats as its a cleaner way to code, but I find myself having to repeat the code for the same output.
for example
if userform1.combox1.value = "something" THEN
COMBOBOX2.VALUE = "SOMETHING ELSE"
if userform2.combox1.value = "something" THEN
COMBOBOX2.VALUE = "SOMETHING ELSE"
AND SO ON.
COULD I NOT WRITE SOMETHING LIKE
IF (WITH ACTIVE USERFORM).combox1.value = "something" THEN
COMBOBOX2.VALUE = "SOMETHING ELSE"
i hope this makes sense.
ok look at this
If UserForm3.Visible Then
Email_Subject = "New" & " " & UserForm3.prodname & " " & UserForm3.TextBox58 & " " & "for" & " " & UserForm3.ComboBox18 & " " & "is ready for Sales Processing"
BODY1 = "I am pleased to inform you that the" & " " & UserForm3.prodname & " " & UserForm3.TextBox58 & " " & "for" _
& " " & UserForm3.ComboBox18 & " " & "is completed and available on the System. Customer Reference:" & " " & EMAIL1.TextBox1 & ", Order No:" & " " & EMAIL1.TextBox2
BODY2 = "QUANTITY: " & " " & EMAIL1.TextBox3
BODY3 = "CAPACITY: " & " " & UserForm3.ComboBox1 & " " & "KG"
BODY4 = "HUB: " & " " & UserForm3.ComboBox7 & " " & "SERIES"
BODY5 = "P.C.D: " & " " & UserForm3.ComboBox10
BODY6 = "DROPARM: " & " " & UserForm3.ComboBox5 & " " & UserForm3.ComboBox6
BODY7 = "ARM ANGLE: " & " " & UserForm3.ComboBox9 & " " & "º"
BODY8 = "c - (OHF): " & " " & UserForm3.TextBox7 & "mm"
BODY9 = "b - (MBC): " & " " & UserForm3.TextBox8 & "mm"
BODY10 = "WHEEL FITTINGS: " & " " & UserForm3.ComboBox17 & " " & UserForm3.ComboBox42
BODY11 = "PART NUMBER FOR FITTING: " & " " & UserForm3.ComboBox37 & " " & UserForm3.ComboBox53
BODY12 = "====================================================================="
BODY13 = "Reason? " & " " & UserForm3.ComboBox52
'BODY14 = "Weight " & " " & UserForm3.TextBox57 & "KG"
BODY15 = "ADDITIONAL INFORMATION: " & " " & EMAIL1.TextBox4
End If
If UserForm4.Visible Then
Email_Subject = "New" & " " & UserForm4.prodname & " " & UserForm4.TextBox58 & " " & "for" & " " & UserForm4.ComboBox18 & " " & "is ready for Sales Processing"
BODY1 = "I am pleased to inform you that the" & " " & UserForm4.prodname & " " & UserForm4.TextBox58 & " " & "for" _
& " " & UserForm4.ComboBox18 & " " & "is completed and available on the System. Customer Reference:" & " " & EMAIL1.TextBox1 & ", Order No:" & " " & EMAIL1.TextBox2
BODY2 = "QUANTITY:" & " " & EMAIL1.TextBox3
BODY3 = "CAPACITY:" & " " & UserForm4.ComboBox1 & " " & "KG"
BODY4 = "HUB:" & " " & UserForm4.ComboBox7 & " " & "SERIES"
BODY5 = "P.C.D:" & " " & UserForm4.ComboBox10
BODY6 = "DROPARM:" & " " & UserForm4.ComboBox5 & " " & UserForm4.ComboBox6
BODY7 = "ARM ANGLE:" & " " & UserForm4.ComboBox9 & " " & "º"
BODY8 = "c - (OHF):" & " " & UserForm4.TextBox7 & "mm"
BODY9 = "b - (MBC):" & " " & UserForm4.TextBox8 & "mm"
BODY10 = "WHEEL FITTINGS:" & " " & UserForm4.ComboBox17 & " " & UserForm4.ComboBox42
BODY11 = "PART NUMBER FOR FITTING:" & " " & UserForm4.ComboBox37 & " " & UserForm4.ComboBox53
BODY12 = "=================================================================================="
BODY13 = "Reason?" & " " & UserForm4.ComboBox52
'BODY14 = "Weight" & " " & UserForm4.TextBox57 & "KG"
BODY15 = "ADDITIONAL INFORMATION:" & " " & EMAIL1.TextBox4
ElseIf UserForm4.CheckBox9 = True Then
BODY12 = "OP55? YES"
ElseIf UserForm4.CheckBox10 = True Then
BODY12 = "OP55? NO"
End If
see how I use the if visible see how I have to repeat the same code twice, once for userform3 and then again for userform4 but the outputs are near the same
Bookmarks