ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   I want to change the background color of cells, if value is a square root. (https://www.excelbanter.com/excel-programming/379108-i-want-change-background-color-cells-if-value-square-root.html)

George C.

I want to change the background color of cells, if value is a square root.
 

I'm looking to change the background color of cells in my
multiplication table, if the value in the cell is a square root.

Following is a portion of the code that a responder here provided on
my original post.

It works fine, and I've not had to change it, but I now wish to change
the cell's background color as described above.

I can't figure out from the book or from online help how I'm even
supposed to access the background's color, let alone change it in the
code.


For ir = 1 To noRows
For ic = 1 To noCols
Cells(ir, ic).Value = ir * ic
Next ic
Next ir

I suspect I have to enter something like "IF ir = ic, THEN . . . . "
before the "Next ic" statement.

TIA
Hrundi

Bob Phillips

I want to change the background color of cells, if value is a square root.
 
For ir = 1 To noRows
For ic = 1 To noCols
Cells(ir, ic).Value = ir * ic
If ir = ic Then
Cells(ir, ic).Interior.ColorIndex = 38
End If
Next ic
Next ir


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"George C." wrote in message
...

I'm looking to change the background color of cells in my
multiplication table, if the value in the cell is a square root.

Following is a portion of the code that a responder here provided on
my original post.

It works fine, and I've not had to change it, but I now wish to change
the cell's background color as described above.

I can't figure out from the book or from online help how I'm even
supposed to access the background's color, let alone change it in the
code.


For ir = 1 To noRows
For ic = 1 To noCols
Cells(ir, ic).Value = ir * ic
Next ic
Next ir

I suspect I have to enter something like "IF ir = ic, THEN . . . . "
before the "Next ic" statement.

TIA
Hrundi





All times are GMT +1. The time now is 02:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com