Excel Flashing Cell

The Flashing Cell When Certain Condition Is Met

         In our example, if the value of cell A1 is greater than 5, this cell starts to flash. The flashing event is realized by changing the background color and font color of the cell at a particular time (firstly red ,then white color) .



         We added a module to ensure the cell flash and paste the following codes into the module:
Sub auto_open()
If Range("A1").Value > 5 Then
Call basla
End If
End Sub

Sub auto_close()
dur = True
End Sub

Sub basla()
If dur = True Then Exit Sub
If Range("A1").Value <= 5 Then
Exit Sub
End If
If Format(Now, "ss") Mod 2 = 0 Then
Range("A1").Interior.Color = vbRed
Range("A1").Font.Color = vbWhite
Range("A1").Font.Size = 11
Range("A1").Font.Bold = True
Else
Range("A1").Interior.ColorIndex = xlNone
Range("A1").Font.Color = vbBlack
Range("A1").Font.Bold = False
End If
Call saat
End Sub

Sub saat()
Application.OnTime Now + TimeValue("00:00:01"), "basla"
End Sub

We enabled the macro to start automatically with VBA auto_open method.
Sub auto_open()
If Range("A1").Value > 5 Then
Call basla
End If
End Sub


Read more ...

Excel Change Background Color of Selected Cells With Scrollbar Control On Userform

Excel VBA: Change Cell's Background Color With Userform


          The userform starts as automatically when the worksheet is opened .Background color of selected cells can be changed with VBA scrollbar control on this userform.
The scrollbar's min value is 0, the maximum value is 56.

The related VBA codes:
Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub ScrollBar1_Change()
TextBox1.Value = ScrollBar1.Value
Selection.Interior.ColorIndex = ScrollBar1.Value
End Sub

Private Sub UserForm_Initialize()
ScrollBar1.Min = 0
ScrollBar1.Max = 56
End Sub


excel change background color


Read more ...

Hide & Unhide Columns With Combobox

Excel VBA Display The Selected A Column From Combobox


excel hide column

                 In this template, only the selected column from the combobox is displayed ,other columns are hidden.The used codes in this template :
Private Sub CheckBox1_Click()
ActiveSheet.Cells.EntireColumn.Hidden = False
End Sub

Private Sub ComboBox1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Me.ComboBox1.DropDown
End Sub

Private Sub UserForm_Initialize()
  Dim lst_column As Integer
    lst_column = ActiveSheet.UsedRange.Columns(ActiveSheet.UsedRange.Columns.Count).Column
For j = 2 To lst_column
   ComboBox1.AddItem Split(ActiveSheet.Cells(1, j).Address, "$")(1) & " " & "-" & Cells(1, j).Value
Next j
End Sub

Private Sub ComboBox1_Change()
   Dim lst_column As Integer
lst_column = ActiveSheet.UsedRange.Columns(ActiveSheet.UsedRange.Columns.Count).Column
    For j = 2 To lst_column
 
     Columns(Split(ActiveSheet.Cells(1, j).Address, "$")(1)).EntireColumn.Hidden = True
Next j
Columns(ComboBox1.ListIndex + 2).EntireColumn.Hidden = False
End Sub


excel hide unhide columns vba

Read more ...