Hi, can you please help me with this task
I want to write a program that takes input of drawing chessboard n x n in excel table (and colors every other field black)
I wrote this code that works:
Option ExplicitSub main()
Dim n As Integer
Dim x As Integer
Dim y As Integer
n = InputBox("Enter number")
For x = 1 To n
For y = 1 To n
Cells(1, 1).Offset(x - 1, y - 1).Interior.ColorIndex = (x + y) Mod 2 + 1
Next y
Next x
End Sub
My question is how i can do this without Offset(x - 1, y - 1).Interior.ColorIndex = (x + y) Mod 2 + 1
and with this code Cells(x,y). Interior.Color = RGB(o,o,o) for each color (black and white)?
Thanks!
I want to write a program that takes input of drawing chessboard n x n in excel table (and colors every other field black)
I wrote this code that works:
Option ExplicitSub main()
Dim n As Integer
Dim x As Integer
Dim y As Integer
n = InputBox("Enter number")
For x = 1 To n
For y = 1 To n
Cells(1, 1).Offset(x - 1, y - 1).Interior.ColorIndex = (x + y) Mod 2 + 1
Next y
Next x
End Sub
My question is how i can do this without Offset(x - 1, y - 1).Interior.ColorIndex = (x + y) Mod 2 + 1
and with this code Cells(x,y). Interior.Color = RGB(o,o,o) for each color (black and white)?
Thanks!