Solved =IF(G2=LIGHT green, B2, 1) on excel

August 16, 2011 at 14:05:45
Specs: Windows XP
Hi All,

This is what I am looking for. Example - If a cell G2's cell color is light green, then h2=b2 or h2=1
Basically I am looking for a Macro which could assign a number in the adjacent cell depending on the color. I have 2 colors. Light green and no color. All the light green cells should take the value in column B depending on the row and all the cells with no color will take a value of 1. I would really appreciate if some one could help me with this

See More: =IF(G2=LIGHT green, B2, 1) on excel

Report •

August 16, 2011 at 15:08:59
✔ Best Answer
Sub GetValIfColor()
Dim lastRw, nxtRw As Integer
 lastRw = Range("B" & Rows.Count).End(xlUp).Row
  For nxtRw = 1 To lastRw
   If Cells(nxtRw, "G").Interior.ColorIndex <> xlNone Then
    Cells(nxtRw, "H") = Cells(nxtRw, "B")
   Else: Cells(nxtRw, "H") = 1
   End If
End Sub

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

August 16, 2011 at 19:07:16
@DerbyDad03: You are awesome..

One more question.. If I have to put the same condition for column C and D, then E and F, do i create a macro for each condition or can they all be done on a single macro? I am sorry for bothering you with my questions. Any help would be appreciated.

Report •

Related Solutions

Ask Question