View Full Version : CommendBox
KK1966
06-17-2008, 10:27 PM
Dear Expert?s
Pleased, would you help me the code of userfrom to show color if Lable2 ? Label1 ( when the result of the values are negative )
Label 3 to show the value = RED.
Please help with billion thanks
KK1966
06-17-2008, 11:23 PM
Expert's ...sorry not clear
Let to rephrases it again as I ought? ness that the message, the calculation should be complete in worksheet, and I just want the userform if the value are ( negative ) Userform would shown me Color RED.
Code is those. ( please help me to modify or learn me the methods with I very appreciate )
Private Sub UserForm_Activate()
Sheets("rtesum").Activate
Label4.Caption = ten30
Label5.Caption = noon
Label6.Caption = rtenbr
Label7.Caption = rtenbr2
Label8.Caption = ten302
Label9.Caption = noon2
Bob Phillips
06-17-2008, 11:52 PM
If Label4.Caption - Label5.Caption < 0 Then
Label4.ForeColor = vbred
End IF
KK1966
06-17-2008, 11:59 PM
Dear XLD
Thanks the help which can learning a much for me, would you mind help one more questions,
to simplfy, If Just base the worksheets values to have ( Nagative ) then the Labelbox to shown in Colors.
please help the code with thanks very very much
Bob Phillips
06-18-2008, 12:00 AM
If Range("A1").Value - Range("A2").Value < 0 Then
Label4.ForeColor = vbRed
End If
KK1966
06-18-2008, 12:10 AM
Thanks very much and get it work now
KK1966
06-18-2008, 12:56 AM
Dear XKD
sorry my again troubles as here's as I base you code to modified, but it can't be work, can u see which was I made wrongs, pleased
since I just beginner thr the excel so.
Thanks very much
Private Sub UserForm_Activate()
Sheets("Sheet1").Activate
Label4.Caption = ten30
If Label4.Caption < 0 Then
Label4.ForeColor = vbRed
End If
Bob Phillips
06-18-2008, 03:04 AM
What is ten30? You don't seem to have initialised it.
KK1966
06-18-2008, 04:01 AM
DEAR XLD
PROBLEM I HAS SOLVED AS CODE
Now I have query the code is the integer but there was show me RED!! Pleased help me to see if any errors
Private Sub CommandButton1_Click()
Dim cap3001 As Integer
Label15.caption = cap3001
If Label15.caption = cap3001 < 1 Then
Label15.ForeColor = vbRed
End If
The name cap3001 that?s means I have around 500 Label Named with huge data
Also if ( 1.5 ) which Hr , why there would shown me RED
Cosmo
06-18-2008, 06:49 AM
You're not resetting the ForeColor of Label15 (unless you're resetting it somewhere else in your code), which means once it's set to red, it will always be red.
Private Sub CommandButton1_Click()
Dim cap3001 As Integer
Label15.Caption = cap3001
If Label15.Caption = cap3001 < 1 Then
Label15.ForeColor = vbRed
Else
Label15.ForeColor = vbBlack
End If
End Sub
Plus, you're setting your caption to an integer variable (cap3001) without setting the value of that variable (so it's 0). In this case, your if statement will always be true (< 1).
KK1966
06-18-2008, 07:10 AM
Dear Cosmo
Thanks so much and pleasant to have learning more from you, beside
if I want in last code before (End Sub) to active the Label = caption to another sheets ( likes Sheet5 ).
How can i start it,
Smaple here's but not work!!!:(
With sheets("shsst5")
Label110.caption = Range("D6")
KK1966
06-18-2008, 07:15 AM
Dear Cosmo
Thanks so much and pleasant to have learning more from you, beside
if I want in last code before (End Sub) to active the Label = caption to another sheets ( likes Sheet5 ).
How can i start it,
Smaple here's but not work!!!:(
With sheets("shsst5")
Label110.caption = Range("D6")
Bob Phillips
06-18-2008, 07:19 AM
Label110.caption = sheets("shsst5").Range("D6").Value
KK1966
06-18-2008, 07:27 AM
Dear Experts
Thanks all of your help
KK1966
06-18-2008, 08:19 AM
Hi, Experts
I had reset all the statements to following your leading as
( Unknow why the caption come up remained in RED ")
Private Sub CommandButton1_Click()
On Error GoTo doerror
Dim cap3001 As VariantLabel15.Caption = cap3001
If Label15.Caption = cap3001 < 0 Then
Label15.ForeColor = vbRed
Else
Label15.ForeColor = vbBlack
End If
End Sub
KK1966
06-18-2008, 08:34 AM
Expert's
Please help to see belowe is the parts of code shorted what's part's marking wrong ....your help I really appreciate
Private Sub CommandButton3_Click()
Route_Status.Hide
End Sub
Private Sub CommandButton2_Click()
Area_Status.TextBox1.Text = ""
End Sub
Private Sub CommandButton1_Click()
On Error GoTo doerror
Dim cap3001 As interger
Label2.caption = Now()
Sheets("Sheet1").Activate
cap3001 = Application.WorksheetFunction.VLookup(Val(TextBox1), range("b6:da106"), 21, False)
Label15.caption = cap3001
If Label15.caption = cap3001 < 0 Then
Label15.ForeColor = vbRed
Else
Label15.ForeColor = vbBlack
End If
If TextBox2.Text = "" Then TextBox2.Text = 0
cap3002 = Application.WorksheetFunction.VLookup(Val(TextBox2), range("b6:da106"), 21, False)
Label332.caption = Sheets("Sheet5").range("D6").Value
Exit Sub
doerror:
MsgBox "no such rte"
End Sub
Bob Phillips
06-18-2008, 08:40 AM
This line
If Label15.caption = cap3001 < 0
is saying, set the caption to the result of 'is cap3001 < 0', in other words TRUE or FALSE. What are you trying to do?
KK1966
06-18-2008, 06:13 PM
Dear's
Thais the UserFrom would shown me as image attached,
unknow why the interger that's also shown to RED ?
How's do I can modify the code.
Please have you advised
KK1966
06-18-2008, 07:51 PM
All's
The problems was settled just change
If Label15.caption < 0 Then .............this ok ,
thanks all the help
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.