vb.net - Excel issue - changing cell color

quahog

Well-known member
Joined
Jul 1, 2003
Messages
69
Location
dc
Does anyone know how to change the color of an Excel cell from within vb.net? Or change the color of the text within the cell. Either would be a help.

Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Add
oSheet = oBook.Worksheets(1)
oSheet.Range("A1:J1").Font.name = "arial black"
oSheet.Range("A1:J1").Font.Bold = True
oSheet.Range("A1:J1").Font.size = 10
oSheet.Range("A1:J1").??????

I have tried every variation that I could think of. Any help would be greatly appreciated.

Regards,

Q
 
Last edited by a moderator:
Try using .Color or .ColorIndex
Code:
Change font color
Range("A1:J1").Font.Color = RGB(255, 0, 0)
Range("A1:J1").Font.ColorIndex = 3
Change cells interior color
Range("A1:J1").Interior.Color = RGB(255, 0, 0)
Range("A1:J1").Interior.ColorIndex = 3
 
Back
Top