Please help! vba chessboard

Ort1z98

New Member
Joined
Jun 27, 2013
Messages
7
Help me with this please its a homework

Sub MM1()
For c = 1 To 8
For r = 1 To 8
Cells(1, 1).Offset(r - 1, c - 1).Interior.ColorIndex = (r + c) Mod 2 + 1
Next r
Next c
End Sub

The answer is ok but i haven´t seen mod in my class yet. I have to use for to and it seems that the answer includes IF. Can you please help me with this, its a homework that i need to do for today

Thanks :smile:
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I don't understand your question - are you trying to get help with the macro or understand what Mod is?
 
Upvote 0
I don't understand your question - are you trying to get help with the macro or understand what Mod is?
I am trying to get help with the macro
(r + c) Mod 2 + 1 I can´t use this because my teacher wont let me. He told me I can create the chessboard using for to and if. Please help me with this
 
Upvote 0
Look, I'm not going to do your homework for you - so what do you have so far for your own code?
 
Upvote 0
Sub MM1()
For c = 1 To 8
For r = 1 To 8
Cells(1, 1).Offset(r - 1, c - 1).Interior.ColorIndex = (r + c) Mod 2 + 1
Next r
Next c
End Sub

This is what i have so far. but it seems i can´t use Mod. Instead i have to use if but I don´t know how to apply it here
 
Upvote 0

Forum statistics

Threads
1,223,723
Messages
6,174,123
Members
452,546
Latest member
Rafafa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top