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

Hjemmet

Board Regular
Joined
Jun 20, 2018
Messages
180
I have put your new code on my userform but not all the Labels Works

as it should

:(
 

Some videos you may like

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,786
Office Version
365
Platform
Windows
Can you please post the code that is not working & explain why?
 

Hjemmet

Board Regular
Joined
Jun 20, 2018
Messages
180
this is the second Resetlabels code i get from you
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
but on my userform1 there are 16 Labels for "E" and 8 Labels for "I" and 4 Labels for "M" and 2 Labels for "R" where my Labels get there Value's
and some of the Labels Don't show anything at all
and some of the Labels Flash as they should
and My commandbuttons Works
 
Last edited:

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,786
Office Version
365
Platform
Windows
In your latest file, you have changed all the command button codes, so none of them work!
 

Hjemmet

Board Regular
Joined
Jun 20, 2018
Messages
180
I take a look on it later to day
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,786
Office Version
365
Platform
Windows
This should do the Reset
Code:
Sub resetLabels()
   With Sheets("Cup 128")
        J = 39
      For i = 264 To 307 Step 6
         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 12
         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)
         Me.Controls("Label" & J + 1).BackColor = IIf(.Range("H" & i + 1).Value, vbRed, vbWhite)
         J = J + 1
      Next i
      For i = 273 To 298 Step 24
         J = J + 1
         If .Range("M" & i).Value <> False Then Me.Controls("Label" & J).Caption = .Range("M" & i).Value
         If .Range("M" & i + 1).Value <> False Then Me.Controls("Label" & J + 1).Caption = .Range("M" & i + 1).Value
         Me.Controls("Label" & J).BackColor = IIf(.Range("L" & i).Value, vbRed, vbWhite)
         Me.Controls("Label" & J + 1).BackColor = IIf(.Range("L" & i + 1).Value, vbRed, vbWhite)
         J = J + 1
      Next i
      For i = 285 To 286 Step 2
         J = J + 1
         If .Range("R" & i).Value <> False Then Me.Controls("Label" & J).Caption = .Range("R" & i).Value
         If .Range("R" & i + 1).Value <> False Then Me.Controls("Label" & J + 1).Caption = .Range("R" & i + 1).Value
         Me.Controls("Label" & J).BackColor = IIf(.Range("Q" & i).Value, vbRed, vbWhite)
         Me.Controls("Label" & J + 1).BackColor = IIf(.Range("Q" & i + 1).Value, vbRed, vbWhite)
         J = J + 1
      Next i
   
   End With
End Sub
 

Hjemmet

Board Regular
Joined
Jun 20, 2018
Messages
180
Again you DID it....

Thank YOU so much for your Time to Figure IT out

it WORKS like a Shinning Diamond
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,786
Office Version
365
Platform
Windows
You're welcome & thanks for the feedback
 

Hjemmet

Board Regular
Joined
Jun 20, 2018
Messages
180
A Single option :)

on my userform1 after the new Code i got it works as it should be

i need a little option wher Label 70 Shows Me Who's the Winner is, it Possibel Just to Get the Winner Show in My Label70
right now my Label68 and 69 show the Player with Red Bagground as the looser of the Game

Label70 looks on Cell "R285" and "R286"
 
Last edited:

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,786
Office Version
365
Platform
Windows
You can just add a line of code into the last two commandbuttons, to change the caption of Label70
 

Watch MrExcel Video

Forum statistics

Threads
1,102,542
Messages
5,487,473
Members
407,603
Latest member
jortronm

This Week's Hot Topics

Top