Ask Your Question

How to set cell color with basic

asked 2017-12-03 15:14:59 +0100

digifoss gravatar image

updated 2017-12-03 15:20:46 +0100

Using LO on Win_64. I have a spreadsheet that creates a table showing increments in feet and inches, with feet shown in column A, and inches in column B. The first row will be 0 and 0 in columns A and B, the second will be 0 and 1, then 0 and 3, and so on until the 12th row which will be 1 and 0, then the next row will be 1 and 1 and so on. After the table is generated, I would like to set the cell interior color of every 12th row, or range that begins a new foot with a yellow color to easily find the beginning of each new foot. I was trying to do this with a for loop - for i = 0 to footcount step 12, oCell = mySheet.getCellByPosition(footcount, 0), oCell.Backcolor =RGB(255,255,0), next i - This gives me a runtime error "Property or Method not found: Backcolor". Searching for this has given me plenty of examples of how to get the color of a cell, but not how set the color of a cell or range of cells.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2017-12-03 15:28:05 +0100

JohnSUN gravatar image

What about oCell.CellBackColor = RGB(255,255,0)?

edit flag offensive delete link more


That gives me the same error

digifoss gravatar imagedigifoss ( 2017-12-03 15:34:10 +0100 )edit

Actually, your answer is correct. I discovered that I had not entered it correctly. Thank you and Ill mark it answered.

digifoss gravatar imagedigifoss ( 2017-12-03 15:54:08 +0100 )edit

And what about oCell = mySheet.getCellByPosition( i ,0) not footcount?

JohnSUN gravatar imageJohnSUN ( 2017-12-03 15:54:31 +0100 )edit

Yes, that was one of the things I had wrong. Your original answer was the right one and I have it working now. Thank you.

digifoss gravatar imagedigifoss ( 2017-12-03 15:57:29 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-12-03 15:14:59 +0100

Seen: 60 times

Last updated: Dec 03 '17