{"id":542,"date":"2016-11-07T08:00:37","date_gmt":"2016-11-07T08:00:37","guid":{"rendered":"http:\/\/99excel.com\/home\/?p=542"},"modified":"2021-05-14T16:08:30","modified_gmt":"2021-05-14T16:08:30","slug":"how-to-return-background-color-of-cell-vba-code-resolved","status":"publish","type":"post","link":"https:\/\/99excel.com\/home\/how-to-return-background-color-of-cell-vba-code-resolved\/","title":{"rendered":"How to return background color of cell &#8211; Vba Code resolved"},"content":{"rendered":"<p>Copy &amp; paste below&nbsp;VBA code&nbsp;in your Module &amp; use function &#8220;<span style=\"color: #0000ff;\">=CellColorIndex(A2)<\/span>&#8221; in sheet.<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #0000ff;\">Function CellColorIndex(InRange As Range, Optional OfText As Boolean = False) As Integer<\/span><br \/>\n<span style=\"color: #0000ff;\">&nbsp; &nbsp;&#8216;This Code created by Akumar, www.99excel.com<\/span><br \/>\n<span style=\"color: #0000ff;\">&nbsp; &nbsp;Application.Volatile True<\/span><br \/>\n<span style=\"color: #0000ff;\">&nbsp; &nbsp;If OfText = True Then<\/span><br \/>\n<span style=\"color: #0000ff;\">&nbsp; &nbsp;CellColorIndex = InRange(1, 1).Font.ColorIndex<\/span><br \/>\n<span style=\"color: #0000ff;\">&nbsp; &nbsp;Else<\/span><br \/>\n<span style=\"color: #0000ff;\">&nbsp; &nbsp;CellColorIndex = InRange(1, 1).Interior.ColorIndex<\/span><br \/>\n<span style=\"color: #0000ff;\">&nbsp; &nbsp;End If<\/span><br \/>\n<span style=\"color: #0000ff;\">End Function<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Copy &amp; paste below&nbsp;VBA code&nbsp;in your Module &amp; use function &#8220;=CellColorIndex(A2)&#8221; in sheet. &nbsp; Function CellColorIndex(InRange As Range, Optional OfText As Boolean = False) As Integer &nbsp; &nbsp;&#8216;This Code created by Akumar, www.99excel.com &nbsp; &nbsp;Application.Volatile True &nbsp; &nbsp;If OfText = True Then &nbsp; &nbsp;CellColorIndex = InRange(1, 1).Font.ColorIndex &nbsp; &nbsp;Else &nbsp; &nbsp;CellColorIndex = InRange(1, 1).Interior.ColorIndex &nbsp; &#8230; <a title=\"How to return background color of cell &#8211; Vba Code resolved\" class=\"read-more\" href=\"https:\/\/99excel.com\/home\/how-to-return-background-color-of-cell-vba-code-resolved\/\" aria-label=\"More on How to return background color of cell &#8211; Vba Code resolved\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-542","post","type-post","status-publish","format-standard","hentry"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/99excel.com\/home\/wp-json\/wp\/v2\/posts\/542","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/99excel.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/99excel.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/99excel.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/99excel.com\/home\/wp-json\/wp\/v2\/comments?post=542"}],"version-history":[{"count":2,"href":"https:\/\/99excel.com\/home\/wp-json\/wp\/v2\/posts\/542\/revisions"}],"predecessor-version":[{"id":876,"href":"https:\/\/99excel.com\/home\/wp-json\/wp\/v2\/posts\/542\/revisions\/876"}],"wp:attachment":[{"href":"https:\/\/99excel.com\/home\/wp-json\/wp\/v2\/media?parent=542"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/99excel.com\/home\/wp-json\/wp\/v2\/categories?post=542"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/99excel.com\/home\/wp-json\/wp\/v2\/tags?post=542"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}