Excel-VBA Comparing Column Data -


i new excel vba, , need write code simple task. need compare values in 2 different columns row row, , see if difference exceeds 50. if so, need highlight entire row.

i program in other languages, have basic understanding how works, have no clue how navigate cells/view content inside cells. tried didn't work out (it highlight every single row). simplified compare if values equal or not, no avail (still highlighted) can give me help?

dim strf0_col integer, sf0_col integer dim myrow, counter integer dim rend integer  sub compare_f0()     rend = 100     strf0_col = 307     sf0_col = 317     counter = 0      myrow = 2 rend step 1         application.statusbar = counter & "rows highlighted."         if (cells(myrow, strf0_col).value = cells(myrow, sf0_col).value)             cells(myrow, strf0_col).entirerow.interior.colorindex = 28         end if     next myrow end sub 

thanks in advance

is there reason not use conditional formatting, @doug glancy suggested?

it worked quite fine here me.

in case want give shoot, follows...

  • choose whole row
  • open conditional formatting menu (will depend on excel version. anyway...)
  • add rule =$ku2>$le2+50
  • set format want (maybe fill in yellow?)
  • confirm
  • copy format other rows

notice row index (2, in case) cannot have $ symbol.

hope helps.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

c# - SharpSVN - How to get the previous revision? -

php cli reading files and how to fix it? -