JarrydBarnard
New Member
- Joined
- Jun 11, 2023
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
Hi there,
I've got a set of numbers from 1 - 100 in cells A1 - J10, generated by VBA, and am needing to shade the cells containing numbers divisible by 7, but I have to use the Mod code.
My current code is:
Dim Counter_Row As Integer
Dim Column_Row As Integer
Dim val As Integer
val = 1
For Column_Row = 1 To 10
For Counter_Row = 1 To 10
Cells(Counter_Row, Column_Row).Value = val
val = val + 1
Next Counter_Row
Next Column_Row
End Sub
How would I do this with an If function? So every cell that contains a multiple of 7 needs to be shaded red. I've tried so many different ways but just can't get it right. Please help
I've got a set of numbers from 1 - 100 in cells A1 - J10, generated by VBA, and am needing to shade the cells containing numbers divisible by 7, but I have to use the Mod code.
My current code is:
Dim Counter_Row As Integer
Dim Column_Row As Integer
Dim val As Integer
val = 1
For Column_Row = 1 To 10
For Counter_Row = 1 To 10
Cells(Counter_Row, Column_Row).Value = val
val = val + 1
Next Counter_Row
Next Column_Row
End Sub
How would I do this with an If function? So every cell that contains a multiple of 7 needs to be shaded red. I've tried so many different ways but just can't get it right. Please help