userform Update

Hjemmet

Board Regular
Joined
Jun 20, 2018
Messages
207
I need some Help with my userform i can Read in my textbox and see it in the Cell But my Label's Aint Update until i Restart userform again

on the userform there is Textbox 1 - 16 and Labels from 1- 28 and Command button 1-28
the Commandbutton's Works ( each Command Button Get Labels Flashing when Button is activated) Command button 1 Flash Label 1 and so on to Label 28

Code:
Private Sub CommandButton1_Click()
    Sheets("Cup 128").Range("L5").Value = "1"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label1 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub




Private Sub CommandButton2_Click()
    Sheets("Cup 128").Range("L5").Value = "2"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label2.BackColor
 Set CellToFlash = Me.Label2 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub CommandButton3_Click()
    Sheets("Cup 128").Range("L9").Value = "1"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label3 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub

Private Sub CommandButton4_Click()
    Sheets("Cup 128").Range("L9").Value = "2"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label2.BackColor
 Set CellToFlash = Me.Label4 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub CommandButton5_Click()
    Sheets("Cup 128").Range("L13").Value = "1"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label5 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub

Private Sub CommandButton6_Click()
    Sheets("Cup 128").Range("L13").Value = "2"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label2.BackColor
 Set CellToFlash = Me.Label6 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub CommandButton7_Click()
    Sheets("Cup 128").Range("L17").Value = "1"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label7 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub CommandButton8_Click()
    Sheets("Cup 128").Range("L17").Value = "2"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label8 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub CommandButton9_Click()
    Sheets("Cup 128").Range("L21").Value = "1"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label9 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub CommandButton10_Click()
    Sheets("Cup 128").Range("L21").Value = "2"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label10 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub CommandButton11_Click()
    Sheets("Cup 128").Range("L25").Value = "1"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label11 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub CommandButton12_Click()
    Sheets("Cup 128").Range("L25").Value = "2"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label12 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub CommandButton13_Click()
    Sheets("Cup 128").Range("L29").Value = "1"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label13 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub CommandButton14_Click()
    Sheets("Cup 128").Range("L29").Value = "2"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label14 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub CommandButton15_Click()
    Sheets("Cup 128").Range("L33").Value = "1"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label15 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub CommandButton16_Click()
    Sheets("Cup 128").Range("L33").Value = "2"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label16 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub CommandButton17_Click()
    Sheets("Cup 128").Range("V7").Value = "1"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label17 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub



Private Sub CommandButton18_Click()
    Sheets("Cup 128").Range("V7").Value = "2"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label2.BackColor
 Set CellToFlash = Me.Label18 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub CommandButton19_Click()
    Sheets("Cup 128").Range("V15").Value = "1"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label19 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub



Private Sub CommandButton20_Click()
    Sheets("Cup 128").Range("V15").Value = "2"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label2.BackColor
 Set CellToFlash = Me.Label20 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub CommandButton21_Click()
    Sheets("Cup 128").Range("V23").Value = "1"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label21 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub



Private Sub CommandButton22_Click()
    Sheets("Cup 128").Range("V23").Value = "2"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label2.BackColor
 Set CellToFlash = Me.Label22 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub CommandButton23_Click()
    Sheets("Cup 128").Range("V31").Value = "1"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label23 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub



Private Sub CommandButton24_Click()
    Sheets("Cup 128").Range("V31").Value = "2"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label2.BackColor
 Set CellToFlash = Me.Label24 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub CommandButton25_Click()
    Sheets("Cup 128").Range("AF11").Value = "1"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label25 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub



Private Sub CommandButton26_Click()
    Sheets("Cup 128").Range("AF11").Value = "2"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label2.BackColor
 Set CellToFlash = Me.Label26 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub CommandButton27_Click()
    Sheets("Cup 128").Range("AF27").Value = "1"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label1.BackColor
 Set CellToFlash = Me.Label27 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub



Private Sub CommandButton28_Click()
    Sheets("Cup 128").Range("AF27").Value = "2"
    'Unload Me
    Dim X As Integer
 Dim OrigColor As Long
 Dim NewColor As Long
 Dim CellToFlash As MSForms.Label
 OrigC = ActiveCell.Interior.ColorIndex
 NewColor = RGB(255, 0, 100) ' 1st cell color
 OrigColor = Me.Label2.BackColor
 Set CellToFlash = Me.Label28 ' Cell range to flash
 Do Until X = 5 ' Flash 20 times
 DoEvents
 Start = Timer ' Set timer for 1st flash rate
 Delay = Start + 0.1 ' Set delay for 1st cell color
 Do Until Timer > Delay ' Dountil delay is exceeded = start+1
 DoEvents
 CellToFlash.BackColor = NewColor ' Changes cell color to
 Loop
 Start = Timer ' Set timer for 2nd flash rate
 Delay = Start + 0.1 ' Set delay for 2nd cell color
 Do Until Timer > Delay
 DoEvents
 CellToFlash.BackColor = OrigColor ' Changes cell color to
 Loop
 X = X + 1 ' Loop increment
 Loop
End Sub
Private Sub TextBox1_Change()
    Range("E5").Value = TextBox1.Value ' specify the destination sheet and cell here
    Me.Repaint
End Sub
Private Sub TextBox2_Change()
    Range("E6").Value = TextBox2.Value ' specify the destination sheet and cell here
    Me.Repaint
End Sub
Private Sub TextBox3_Change()
    Range("E9").Value = TextBox3.Value ' specify the destination sheet and cell here
    Me.Repaint
End Sub
Private Sub TextBox4_Change()
    Range("E10").Value = TextBox4.Value ' specify the destination sheet and cell here
    Me.Repaint
End Sub
Private Sub TextBox5_Change()
    Range("E13").Value = TextBox5.Value ' specify the destination sheet and cell here
    Me.Repaint
End Sub
Private Sub TextBox6_Change()
    Range("E14").Value = TextBox6.Value ' specify the destination sheet and cell here
    Me.Repaint
End Sub
Private Sub TextBox7_Change()
    Range("E17").Value = TextBox7.Value ' specify the destination sheet and cell here
    Me.Repaint
End Sub
Private Sub TextBox8_Change()
    Range("E18").Value = TextBox8.Value ' specify the destination sheet and cell here
    Me.Repaint
End Sub
Private Sub TextBox9_Change()
    Range("E21").Value = TextBox9.Value ' specify the destination sheet and cell here
    Me.Repaint
End Sub
Private Sub TextBox10_Change()
    Range("E22").Value = TextBox10.Value ' specify the destination sheet and cell here
    Me.Repaint
End Sub
Private Sub TextBox11_Change()
    Range("E25").Value = TextBox11.Value ' specify the destination sheet and cell here
    Me.Repaint
End Sub
Private Sub TextBox12_Change()
    Range("E26").Value = TextBox12.Value ' specify the destination sheet and cell here
    Me.Repaint
End Sub
Private Sub TextBox13_Change()
    Range("E29").Value = TextBox13.Value ' specify the destination sheet and cell here
    Me.Repaint
End Sub
Private Sub TextBox14_Change()
    Range("E30").Value = TextBox14.Value ' specify the destination sheet and cell here
    Me.Repaint
End Sub
Private Sub TextBox15_Change()
    Range("E33").Value = TextBox15.Value ' specify the destination sheet and cell here
    Me.Repaint
End Sub
Private Sub TextBox16_Change()
    Range("E34").Value = TextBox16.Value ' specify the destination sheet and cell here
    Me.Repaint
End Sub
Private Sub UserForm_Initialize()

Label1.Caption = Sheets("Cup 128").Range("E5").Value
If Label1 = "False" Then
Label1 = ""
Else
End If
Label2.Caption = Sheets("Cup 128").Range("E6").Value
If Label2 = "False" Then
Label2 = ""
Else
End If
Label3.Caption = Sheets("Cup 128").Range("E9").Value
If Label3 = "False" Then
Label3 = ""
Else
End If
Label4.Caption = Sheets("Cup 128").Range("E10").Value
If Label4 = "False" Then
Label4 = ""
Else
End If
Label5.Caption = Sheets("Cup 128").Range("E13").Value
If Label5 = "False" Then
Label5 = ""
Else
End If
Label6.Caption = Sheets("Cup 128").Range("E14").Value
If Label6 = "False" Then
Label6 = ""
Else
End If
Label7.Caption = Sheets("Cup 128").Range("E17").Value
If Label7 = "False" Then
Label7 = ""
Else
End If
Label8.Caption = Sheets("Cup 128").Range("E18").Value
If Label8 = "False" Then
Label8 = ""
Else
End If
Label9.Caption = Sheets("Cup 128").Range("E21").Value
If Label9 = "False" Then
Label9 = ""
Else
End If
Label10.Caption = Sheets("Cup 128").Range("E22").Value
If Label10 = "False" Then
Label10 = ""
Else
End If
Label11.Caption = Sheets("Cup 128").Range("E25").Value
If Label11 = "False" Then
Label11 = ""
Else
End If
Label12.Caption = Sheets("Cup 128").Range("E26").Value
If Label12 = "False" Then
Label12 = ""
Else
End If
Label13.Caption = Sheets("Cup 128").Range("E29").Value
If Label13 = "False" Then
Label13 = ""
Else
End If
Label14.Caption = Sheets("Cup 128").Range("E30").Value
If Label14 = "False" Then
Label14 = ""
Else
End If
Label15.Caption = Sheets("Cup 128").Range("E33").Value
If Label15 = "False" Then
Label15 = ""
Else
End If
Label16.Caption = Sheets("Cup 128").Range("E34").Value
If Label16 = "False" Then
Label16 = ""
Else
End If
Label17.Caption = Sheets("Cup 128").Range("P7").Value
If Label17 = "False" Then
Label17 = ""
Else
End If
Label18.Caption = Sheets("Cup 128").Range("P8").Value
If Label18 = "False" Then
Label18 = ""
Else
End If
Label19.Caption = Sheets("Cup 128").Range("P15").Value
If Label19 = "False" Then
Label19 = ""
Else
End If
Label20.Caption = Sheets("Cup 128").Range("P16").Value
If Label20 = "False" Then
Label20 = ""
Else
End If
Label21.Caption = Sheets("Cup 128").Range("P23").Value
If Label21 = "False" Then
Label21 = ""
Else
End If
Label22.Caption = Sheets("Cup 128").Range("P24").Value
If Label22 = "False" Then
Label22 = ""
Else
End If
Label23.Caption = Sheets("Cup 128").Range("P31").Value
If Label23 = "False" Then
Label23 = ""
Else
End If
Label24.Caption = Sheets("Cup 128").Range("P32").Value
If Label24 = "False" Then
Label24 = ""
Else
End If
Label25.Caption = Sheets("Cup 128").Range("Y11").Value
If Label25 = "False" Then
Label21 = ""
Else
End If
Label26.Caption = Sheets("Cup 128").Range("Y12").Value
If Label26 = "False" Then
Label22 = ""
Else
End If
Label27.Caption = Sheets("Cup 128").Range("Y27").Value
If Label27 = "False" Then
Label27 = ""
Else
End If
Label28.Caption = Sheets("Cup 128").Range("Y28").Value
If Label28 = "False" Then
Label28 = ""
Else
End If
    
End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
There is a serious amount of duplication in your code, sorry but I had to do something about it! This is untested and may contain errors, but please for your own sanity try to incorporate these changes!

Code:
Private Sub CommandButton1_Click()
flash "L5", 1, Me.Label1, Me.Label1
End Sub


Private Sub CommandButton2_Click()
flash "L5", 2, Me.Label2, Me.Label2
End Sub


Private Sub CommandButton3_Click()
flash "L9", 1, Me.Label1, Me.Label3
End Sub


Private Sub CommandButton4_Click()
flash "L9", 1, Me.Label2, Me.Label4
End Sub




Sub flash(strRange As String, iValue As Integer, lblOrig As MSForms.Label, lblFlash As MSForms.Label)


Sheets("Cup 128").Range(strRange).Value = iValue


Dim X As Integer
Dim OrigColor As Long: OrigColor = lblOrig.BackColor
Dim NewColor As Long: NewColor = RGB(255, 0, 100)       ' 1st cell color


OrigC = ActiveCell.Interior.ColorIndex ' ## this is not declared
 
Do Until X = 5                                          ' Flash 20 times
    DoEvents
    Start = Timer                                       ' Set timer for 1st flash rate
    Delay = Start + 0.1                                 ' Set delay for 1st cell color
    
    Do Until Timer > Delay                              ' Do until delay is exceeded = start+1
        DoEvents
        lblFlash.BackColor = NewColor                   ' Changes cell color to
    Loop
    
    Start = Timer                                       ' Set timer for 2nd flash rate
    Delay = Start + 0.1                                 ' Set delay for 2nd cell color
    
    Do Until Timer > Delay
        DoEvents
        lblFlash.BackColor = OrigColor                  ' Changes cell color to
    Loop
    
    X = X + 1                                           ' Loop increment
Loop


End Sub

There's nothing in your code that should affect your captions, so it's probably some instability in the ActiveX control that means it doesn't show properly. A workaround would be to split out that part of the Initialise code that sets the captions, and runs it when necessary - in the following, you have a "resetLabels" code you can call any time you like
Code:
Private Sub UserForm_Initialize()
resetLabels
End Sub


Sub resetLabels()
If Sheets("Cup 128").Range("E5").Value <> False Then Label1.Caption = Sheets("Cup 128").Range("E5").Value
If Sheets("Cup 128").Range("E6").Value <> False Then Label2.Caption = Sheets("Cup 128").Range("E6").Value
If Sheets("Cup 128").Range("E9").Value <> False Then Label3.Caption = Sheets("Cup 128").Range("E9").Value
' etc
End Sub

Hope this helps
 
Upvote 0
Sorry BUT i aint get what you are trying to do with that Code you have sent to mee…

I have now look't my code Again and Didn find any Duble...
 
Upvote 0
Each of your CommandButton_Click routines is essentially the same, with only four variables different in each. This means you've written almost the same thing over and over, 28 times. It's hard to read, and any changes you want to make must be made to every piece of code, which is a slow, painful task with a high risk of missing the change in at least one Sub.

Instead, I've created one piece of code named "flash" which needs the four variables passed into it, so these are declared within the brackets. Each of your buttons then simply calls this same Sub, and tells it which settings to use - the same flash code is used by every CommandButton_Click

Essentially, the code I've created in the first code box above, should be doing exactly the same as your first four CommandButton_Click routines - but my CommandButton_Click routines are only one line each, they call the flash Sub and pass in the four variables that correspond with the four variables declared at the start of Flash


Finally, by pulling out the piece of code that sets your captions, into a separate Sub named resetLabels, I can call this code at any time from anywhere. Add it as the last line of Flash, and it will reset the captions every time this code is run

HTH
 
Upvote 0
Yabba dabba dohhhh

it seems to be like i get the point and It work's

thanks for the Short code insteed of my Mile away Code
 
Upvote 0

Forum statistics

Threads
1,223,882
Messages
6,175,164
Members
452,615
Latest member
bogeys2birdies

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