How to set Color to a cell in Excel
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
24-05-19 02:08 AM
Hi All,
I am trying to fill color to a specific cell in excel, any one has any idea please comment this post.
Â
Thanks in advance..
7 REPLIES 7
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
24-05-19 04:51 PM
Hi,
Depending on your version perhaps can you set rules into Excel to fill this cell here :
https://support.office.com/en-gb/article/apply-create-or-remove-a-cell-style-472213bf-66bd-40c8-815c-594f0f90cd22
If this option does not apply to you, I would recommend to create a VBA Macro to handle it.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
24-05-19 04:52 PM
... then you run the macro from BP with the Excel VBO.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
24-05-19 09:26 PM
Or you can add action to excel VBO to do it, should be easy, code was somewhere on the forum if I remember correctly.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
25-05-19 04:26 PM
Code
Dim xl, wb, ws, r, i, f as object
Try
  xl = GetInstance(Handle)
   if Workbook_Name = "" then
    wb = xl.activeworkbook
  else
     wb = xl.workbooks(Workbook_Name)
      wb.activate
  end if
   ws = wb.activesheet
  if Ref.Trim = "" then
    r = ws.usedrange
   else
      r = ws.range(Ref)
   end if
   i = r.Interior
   i.ColorIndex = Background_Colour
   f = r.Font
   f.ColorIndex = Foreground_Colour
Catch e As Exception
   Success = False
   Message = e.Message
Finally
   xl = Nothing
   wb = Nothing
   ws = Nothing
   i = Nothing
   r = Nothing
   f = Nothing
End Try
Â
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
18-06-20 06:39 PM
You can use the set cell color Action In the MS Excel VBO.
------------------------------
Juan Manuel Fonseca
Rpa developer
Freelance
America/Mexico_City
------------------------------
------------------------------
Juan Manuel Fonseca
Rpa developer
Freelance
America/Mexico_City
------------------------------
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
17-06-21 12:53 PM
Hi!
Where can I find the MS Excel VBO-set cell color Action for downloading?
Thanx
------------------------------
SOFÍA ROLDÁN GARCÍA
------------------------------
Where can I find the MS Excel VBO-set cell color Action for downloading?
Thanx
------------------------------
SOFÍA ROLDÁN GARCÍA
------------------------------
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
24-06-21 01:17 PM
Create additional action in excel vbo
code:
For Each row As DataRow In rowscoll.Rows
GetWorkbook(handle,Nothing).ActiveSheet.Cells(row.Item("Value"),colref).Interior.Color = RGB(Red_Value, Green_Value, Blue_Value)
next row
Inputs to the action:

Action:

ColRef is number of the column
rowscol is collection of row numbers to color
------------------------------
Karol Pietrzyk
------------------------------
code:
For Each row As DataRow In rowscoll.Rows
GetWorkbook(handle,Nothing).ActiveSheet.Cells(row.Item("Value"),colref).Interior.Color = RGB(Red_Value, Green_Value, Blue_Value)
next row
Inputs to the action:
Action:
ColRef is number of the column
rowscol is collection of row numbers to color
------------------------------
Karol Pietrzyk
------------------------------
