PDA

View Full Version : Color i cell


Juha
10-05-03, 07:04
Hi, i'm wondering if its possible to easy make every second cell gray?

sugarflux
10-05-03, 08:42
You can write a macro.

Dim myRow as Integer

Cells(1, 1).Activate 'Set the starting cell

myRow = 0
Do
myRow=myRow+2

Cells(myRow, 1).Interior.Colorindex = 15

Loop Until myRow = 1000 'Number of rows you want to go down

RickKnight
10-05-03, 09:02
On the outter border of the speadsheet, right click at the intersection of where the row and columns meet. This will highlight the entire sheet. Then click 'format cells' and set the colors.


Originally posted by Juha
Hi, i'm wondering if its possible to easy make every second cell gray?

Juha
10-05-03, 12:30
Thanks sugarflux
it works great!

But just one qusteion, how do i fill like 7 cells i row
and why cant i fill the cells twice?

sugarflux
10-06-03, 04:50
If you want to fill a group of cells without blanks, you just change the
myRow = myRow+2 to
myRow = myRow+1

If you want to extend the macro to cover columns, you can put the same piece of code in the middle of the original code.
ie.

Dim myRow as Integer
Dim myColumn as Integer

myRow = 0
myColumn = 0

Cells(1, 1).Active ' Set Starting Cell

Do
myRow = myRow+1

Do
myColumn = myColumn + 1
Cells(myRow, myColumn).Interior.Colorindex = 15
Loop Until myColumn = 1000 ' Number of columns

Loop Until myRow = 1000 ' Number of Rows

Hope this helps!
Dan

Juha
10-06-03, 13:31
i got it working now....thanks alot sugarflux