Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

move and highlighted data of range based on cell value

0

hi, all

i search  macro  to  highlight  data  of range and  move  from row   to  another  based on cell value  in j3   ,  in this  file   highlights  the  whole  row  based on active sheet   but  what  i  want   higlighting  the  data range  from a2:f  based on j2    based on  column c  every  word write  in j2  then highlighting  and  if  i  change  another  word  in j2  move  colored range  based on column c

Answer
Discuss

Answers

0
Selected Answer

Leopard, not sure I fully understand what you're trying to do but guess you want to highlight rows (in columns A to F) based on a search value in cell J3 (and possibly matching customers in column C).

You don't need a macro to do that- it can be done by conditional formatting- see the attached (no-macro) version of your file. If you change the value in J3, the row highlighting will change to suit to the appropriate matching row. Note that it your data table has two or more rows with a matching value in column C, they will appear green.

It works because I've set the conditional formatting in cells A2:F8 to have a green fill based uf this formula is true (for C2 and likewise for other cells in C) :

=IF($C2=$J$3,1)

That IF statement returns a 1 (=Boolean True) when the value if C2 matches matches that in the (fixed) search cell $J$3.

Note that the formula was written in row 2 with only 1 $ sign (to fix the column C but not the row number)- that means when it's extended to other rows, the 2 changes to 3, 4, 5 or whatever so those cells get compared with the fixed $J$3.

If that doesn't suit, I suggest you edit your question to show what simple steps you want to do with which data. Also please state which library is used with your macro (it didn't work for me). 

Discuss

Discussion

great ! john       honestly   i'm very  suprised  doing  that  by  formula    it's  very  quick  and  efficient  this  is  exactly  what  i'm looking for    ,many  thanks  for  your  answering 
leopard (rep: 88) Dec 17, '20 at 1:02 am
Thanks Leopard, glad it worked for you. Another non-VBA way to display searched rows (but without colouring rows) would be to set a filter on column C. 
John_Ru (rep: 6152) Dec 17, '20 at 1:41 am
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login