excel vba - Compare column and colour the cell if not matched -


i have 2 columns comparing 2 columns. first column 'b' checking column 'xfd' , if values not matching, cells groundcolour changed red. simultaniously, check if column 'c' matching column'xfc'.

i want color column 'c' if values not matching coding changing colour if values matching. please advise on coding.

column b  column c     column 'xfc    column 'xfd'  q1          jan-15      jan-15           q1 q2          oct-15      feb-15           q1 q3          jul-15      mar-15           q1 q4          dec-15      apr-15           q2                         may-15           q2                         jun-15           q2                         jul-15           q3                         aug-15           q3                         sep-15           q3                         oct-15           q4                         nov-15           q4                         dec-15           q4 

coding

application.screenupdating = false   dim stnow date   dim lasta long   lasta = range("b" & rows.count).end(xlup).row    dim lastb long   lastb = range("xfd" & rows.count).end(xlup).row   dim match boolean   dim long, j long   dim r1 range, r2 range   = 2 lasta    set r1 = range("b" & i)    match = false    j = 2 lastb       set r2 = range("xfd" & j)       if r1 = r2          match = true          if range("b" & i).offset(0, 1) = range("xfd" & j).offset(0, -1)              range("b" & i).offset(0, 1).interior.color = rgb(255, 0, 0)           end if       end if    next j next  application.screenupdating = true 

try ...

application.screenupdating = false dim stnow date dim lasta long dim lastb long dim long dim j long dim r1 range dim r2 range dim i_store integer  lasta = range("b" & rows.count).end(xlup).row lastb = range("xfd" & rows.count).end(xlup).row  = 2 lasta    set r1 = range("b" & i)    i_store = 0    j = 2 lastb       set r2 = range("xfd" & j)       if r1.value = r2.value          if range("b" & i).offset(0, 1) = range("xfd" & j).offset(0, -1)               i_store = 0             exit          else             if i_store = 0                i_store =             end if          end if        end if    next j    if i_store > 0       range("b" & i_store).offset(0, 1).interior.color = rgb(255, 0, 0)    end if  next  application.screenupdating = true 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -