Last active
March 10, 2019 12:18
-
-
Save ezhov-da/96b6c9da8c808b129251171f698d0092 to your computer and use it in GitHub Desktop.
vba разукрашивание ячеек рандомным цветом.vba
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub startPaintExcel() | |
Cells.Delete Shift:=xlUp | |
Columns.ColumnWidth = 0.6 | |
Rows.RowHeight = 5.8 | |
Dim rowMax As Integer: rowMax = 1000 | |
Dim columnMax As Integer: columnMax = 1000 | |
For r = 1 To rowMax | |
For c = 1 To columnMax | |
If (r Mod 2 = 0) And (c Mod 2 = 0) Then | |
Cells(r, c).Interior.ColorIndex = getRandomNumber() | |
End If | |
If (r Mod 2 <> 0) And (c Mod 2 <> 0) Then | |
Cells(r, c).Interior.ColorIndex = getRandomNumber() | |
End If | |
Next c | |
Next r | |
End Sub | |
Private Function getRandomNumber() As Integer | |
getRandomNumber = Int((56 - 1 + 1) * Rnd + 1) | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment