View Full Version : get an error if i press calculate-1 button without entries in the 4 Labels in Red
How do i change code in the userform so that i must have entries in the following Textboxs which are Red in colour on the Userform....i get an error if i hit the Calculate-1 button without entries in these 4 textbox`s
System Feed Flow
Feed Concentration
Outlet Concentration
CT Feed Flow
Also how do i make the results show as whole numbers?
Also can the colour of the numbers in the result box`s be Blue?
Still new to VBA code so i have i made this coding correct...it does work though
Best Regards
Jeff
shaka
10-03-2013, 01:02 AM
Hi Jeff still new to VBA myself but I think this should work at the end of your command button code
If UserForm1.TextBox7.Value = "" Then
MsgBox "Please enter a System Flow Rate"
Exit sub
End If
also use this example to change the font colour
Me.TextBox7.ForeColor = vbBlue
hope this helps
bakerman
10-03-2013, 02:43 AM
Put following code at start of commandbutton-code
For Each it In Array(7, 8, 9, 17)
If Me("Textbox" & it) = vbNullString Then MsgBox "Missing value": Exit Sub
Next
Coloring textboxtext will only work if enabled. They are now greyed out because of disabling them.
Thanks for help
When all entries are in the userform i then want this transferred to Result Sheet...the code i used gives error...where have i gone wrong please
When i transfer the 1st data to column D , the next entries into column E through to column I
Jeff
I made a couple of changes but still get error
I tried by changing Rows to column in code but still error
Regards
Jeff
bakerman
10-05-2013, 07:16 PM
Private Sub CommandButton5_Click()
With Sheets("RESULTS")
myarray = Array(TextBox7.Value, TextBox8.Value, TextBox9.Value, , TextBox4.Text, TextBox5.Text, , _
TextBox6.Text, TextBox1.Text, , TextBox2.Text, TextBox3.Text, , TextBox10.Text, TextBox11.Text, , _
TextBox12.Text, TextBox13.Text, TextBox14.Text, TextBox15.Text, TextBox16.Text, , _
TextBox17.Value, TextBox18.Text, TextBox19.Text, TextBox20.Text, TextBox21.Text)
mycol = .Cells(6, .Columns.Count).End(xlToLeft).Offset(, 1).Column
For i = 0 To UBound(myarray)
.Cells(i + 6, mycol) = myarray(i)
Next
End With
MsgBox "Data Transferred"
End Sub
Thank you
I keep getting a zero number for Textbox5....tried changing the formula but always get a zero?
In the userform i get some numbers with a decimal point...can all answers be a whole number?
Cheers
bakerman
10-05-2013, 08:58 PM
Check the order of Textbox-calculation in your Calculate-code.
Check F1 for rounding numbers( Round, Roundup, Rounddown)
I must be missing something here as i have tried many combinations to get a value in Solids in Concentration (userform Textbox5)....the values are visible in all textboxs on Userform except for the value in Textbox5
Jeff
bakerman
10-06-2013, 11:43 AM
jeff,
To calculate TB5 you need the value of TB1 too, but TB1 is still empty at that time because you only calculate it's value two steps further in your code.
Hello bakerman
yes a bad miss by me
what advice would you give for learning VBA...do you recommend any books?
Cheers
Jeff
bakerman
10-06-2013, 01:45 PM
There maybe dozens of books on the market so saying this one or that one is rather difficult.
The macro-recorder is a good place to start. Just record all the steps you take and look what code comes out.
Then you can start by shortening that code by eliminating Select, Selection, Activate because in 99% of the cases it's unnecessary.
A lot of trial and error and visiting forums to view codes and learning from that also helps a lot.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.