Label Change Color When Text in cell is "true" on userform

Hjemmet

Board Regular
Joined
Jun 20, 2018
Messages
207
i have this kind of Code in vba on my userform

Code:
Sub resetLabels()
If Sheets("Cup 128").Range("E5").Value <> False Then Label1.Caption = Sheets("Cup 128").Range("E5").Value
End Sub

this part works fine But when i try to put the Code Below into my code then the label get Red
when Start userform and no data in Cell ("D5")

I have try to get this code into it for change the Color if ("D5") have the right Text ("Text")

Code:
If Sheets("Cup 128").Range("D5").Text = "True" Then
        Me.Label1.BackColor = vbRed
        End If

but it aint work
 
HM HM HM i thanks for the idea But that Combo stuff give me LONG hair

but give it a try any way

thanks for you help So Far
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I have now Try you Solution and put code in and made a Single userform And combo work but code stop with error in this Line

Code:
Sub resetLabels()   With Sheets("Cup 128")
      For i = Rw To Rw + 29 Step 4
         j = j + 1
         If .Range("E" & i).Value <> False Then[COLOR=#ffff00] [/COLOR][COLOR=#ff0000]Me.Controls("Label" & j).Caption = .Range("E" & i).Value[/COLOR][COLOR=#ffff00][/COLOR]
         If .Range("E" & i + 1).Value <> False Then Me.Controls("Label" & j + 1).Caption = .Range("E" & i + 1).Value
         Me.Controls("Label" & j).BackColor = IIf(.Range("D" & i).Value, vbRed, vbWhite)
         Me.Controls("Label" & j + 1).BackColor = IIf(.Range("D" & i + 1).Value, vbRed, vbWhite)
         j = j + 1
      Next i
 
Upvote 0
I must SAY that Was Brilliant

i thanks for that Idea and will use it for my Big file Later with Lots of Game Solutions

SO Thanks Again for you help
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
Hey Fluff First of all Thanks Again for Your Help so far..

the first 1-8 works Brilliant

but i Need some help with the Last And most Importen Board "The Finale Games from the last 16 Players who run Through Round 1 to 8

and on that Userform there are NO textbox's Only Labels from Label40 to Label69
Label40 to Label55 takes data from "E264 to E306" 16 players left 1/8 Finale)
Label56 to Label63 takes data from "I267 to E304" 8 Players left (Quarter Finale)
Label64 to Label67 takes data from "M273 to M298" 4 Players left (semi Finale)
Label68 to Label69 takes data from "R265 to R266" 2 Players left (Finale)

Label70 came by read cell where Vwinner is

and Same numbers of Commandbuttons (CB) start from
CB40 for Label40 to CB55 for Label55
CB56 for Label56 to CB63 for label63
CB64 for Label64 to CB67 for Label67
CB68 for Label68 to CB69 for Label69

Hope that was enough
 
Upvote 0
Use this
Code:
Sub resetLabels()
   With Sheets("Cup 128")
        J = 39
      For i = 264 To 307 Step 4
         J = J + 1
         If .Range("E" & i).Value <> False Then Me.Controls("Label" & J).Caption = .Range("E" & i).Value
         If .Range("E" & i + 1).Value <> False Then Me.Controls("Label" & J + 1).Caption = .Range("E" & i + 1).Value
         Me.Controls("Label" & J).BackColor = IIf(.Range("D" & i).Value, vbRed, vbWhite)
         Me.Controls("Label" & J + 1).BackColor = IIf(.Range("D" & i + 1).Value, vbRed, vbWhite)
         J = J + 1
      Next i
      For i = 267 To 304 Step 8
         J = J + 1
         If .Range("I" & i).Value <> False Then Me.Controls("Label" & J).Caption = .Range("I" & i).Value
         If .Range("I" & i + 1).Value <> False Then Me.Controls("Label" & J + 1).Caption = .Range("I" & i + 1).Value
         Me.Controls("Label" & J).BackColor = IIf(.Range("H" & i).Value, vbRed, vbWhite)
         J = J + 1
      Next i
   End With
End Sub
This will get rid of the problem when loading the form, but some of your commandbuttons are looking at the labels/buttons
 
Upvote 0
Code:
https://www.dropbox.com/s/u87vnpomy0nfenj/total%20changes.xlsm?dl=0

new link to my file Just try it at Work after i got some spare time (LOL)
 
Upvote 0
Is it working?
If not what problems do you get?
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top