Reputation: 387
Is there a way to highlight/fill the cells in row x a given colour from a visual basic application? I can read and write to cells but can't find syntax to format cells or entire rows if possible.
Edit: code for Read/Write
Dim APP As New Excel.Application
Dim worksheet As Excel.Worksheet
Dim workbook As Excel.Workbook
workbook = APP.Workbooks.Open(InputFile)
worksheet = workbook.Worksheets(1)
Read:
Arr(i, 0) = worksheet.Cells(rowcount, 14).value
Write:
worksheet.Cells(row, Col).value = Arr(i, 2)
Upvotes: 1
Views: 1737
Reputation: 399
Yeah you can. Use code like:
Range("A1").Interior.Color = RGB(255, 0, 0)
You can set range like.. Range("A1:A10")
For all cells in row(1):
Rows(1).Interior.Color = RGB(255, 0, 0)
@Edit
Also possible to set colors via ColorIndex for example:
Range("A1").Interior.ColorIndex = 37
Upvotes: 1