Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

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

Edited by quahog
when the day is bad and life's a curse, cheer up tomorrow may be worse.
Posted

Try using .Color or .ColorIndex

'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

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...