Public Sub FillOddsAndEvens()
With Range("A1:T22")
.Formula = "=IF(and(isodd(row(a1)),isodd(column(a1))),""Odd"", if(and(iseven(row(a1)),iseven(column(a1))),""Even"",""""))"
.Value = .Value
End With
End Sub
Public Sub FillOddsAndEvens()
Dim fillrange As Range
Dim filltext As String
Dim numcols As Long, numrows As Long, fillcolor As Long, i As Long, j As Long
Set fillrange = Range("A1:T22")
With fillrange
numcols = .Columns.Count
numrows = .Rows.Count
End With
Application.ScreenUpdating = False
For i = 1 To numrows
If ((i Mod 2) = 0) Then
fillcolor = vbWhite
filltext = "Even"
Else
fillcolor = vbYellow
filltext = "Odd"
End If
For j = 1 To numcols
With fillrange.Cells(i, j)
If ((j Mod 2) = (i Mod 2)) Then
.Value = filltext
.Interior.Color = fillcolor
End If
fillcolor = IIf(fillcolor = vbWhite, vbYellow, vbWhite)
End With
Next
Next
Application.ScreenUpdating = True
End Sub
Public Sub FillOddsAndEvens2()
Dim fillrange As Range
Dim filltext As String
Dim fillcolor As Long
Dim c As Range
Set fillrange = Range("A1:T22")
Application.ScreenUpdating = False
For Each c In fillrange
If (c.Column Mod 2) = (c.Row Mod 2) Then
fillcolor = vbYellow
filltext = "Even"
If ((c.Row Mod 2) = 1) Or ((c.Column Mod 2) = 1) Then filltext = "Odd"
Else
fillcolor = vbWhite
filltext = ""
End If
c.Interior.Color = fillcolor
c.Value = filltext
Next
Application.ScreenUpdating = True
End Sub
Public Sub FillOddsAndEvens3()
Dim fillrange As Range
Dim filltext As String
Dim numcols As Long, numrows As Long, fillcolor As Long, i As Long, j As Long
Dim myArr(1 To 22, 1 To 20) As String
Set fillrange = Range("A1:T22")
With fillrange
numcols = .Columns.Count
numrows = .Rows.Count
End With
Application.ScreenUpdating = False
For i = 1 To numrows
If ((i Mod 2) = 0) Then
fillcolor = vbWhite
filltext = "Even"
Else
fillcolor = vbYellow
filltext = "Odd"
End If
For j = 1 To numcols
With fillrange.Cells(i, j)
If ((j Mod 2) = (i Mod 2)) Then
myArr(i, j) = filltext
'.Interior.Color = fillcolor
End If
fillcolor = IIf(fillcolor = vbWhite, vbYellow, vbWhite)
End With
Next
Next
'Write all values to the worksheet
Range("A1:T22").Value = myArr
Application.ScreenUpdating = True
End Sub