Related:
- Repainting a cell using excel VBA
- Number to words in excel formula without vba - Guide
- Vba case like - Guide
- Excel mod apk for pc - Download - Spreadsheets
- How to open vba in excel - Guide
- Excel marksheet - Guide
2 responses
Try this at the beginning of the code. This will clear all cells in the worksheet that are colored.
Cells.Select
Selection.Interior.ColorIndex = xlNone
Cells(2, 3).Select
Private Sub CommandButton2_Click()
Dim a1 As Integer
Dim d1 As Integer
Dim r1 As Integer
Cells.Select
Selection.Interior.ColorIndex = xlNone
Cells(2, 3).Select
a1 = Sheet1.Cells(2, 3)
d1 = a1 \ 8
r1 = a1 Mod 8
If d1 >= 5 Then
Sheet1.Cells.Range("A20:E20").Interior.Color = vbBlack
Else
For cnt = 1 To d1
Sheet1.Cells(20, cnt).Interior.Color = vbBlack
Next cnt
If r1 <> 0 Then
Sheet1.Cells(20, cnt).Interior.Color = vbBlack
Sheet1.Cells(20, cnt).Font.Color = vbWhite
Sheet1.Cells(20, cnt) = (8 - r1)
End If
End If
End Sub
Cells.Select
Selection.Interior.ColorIndex = xlNone
Cells(2, 3).Select
Private Sub CommandButton2_Click()
Dim a1 As Integer
Dim d1 As Integer
Dim r1 As Integer
Cells.Select
Selection.Interior.ColorIndex = xlNone
Cells(2, 3).Select
a1 = Sheet1.Cells(2, 3)
d1 = a1 \ 8
r1 = a1 Mod 8
If d1 >= 5 Then
Sheet1.Cells.Range("A20:E20").Interior.Color = vbBlack
Else
For cnt = 1 To d1
Sheet1.Cells(20, cnt).Interior.Color = vbBlack
Next cnt
If r1 <> 0 Then
Sheet1.Cells(20, cnt).Interior.Color = vbBlack
Sheet1.Cells(20, cnt).Font.Color = vbWhite
Sheet1.Cells(20, cnt) = (8 - r1)
End If
End If
End Sub