Excel VBA Macro to make highlighted cells be the same as the next non-highlighted cell above it

ariesmethod

New Member
Joined
Apr 17, 2014
Messages
9
This sounds complicated, but this is what I have to make a macro of for work. Listed below is a sample of the list of item codes that I have: ('h' stands for highlighted cell)


M101
S644 (h)
S753 (h)
M102
S531 (h)
etc....


I want to make the macro to give this end result using any method:


M101
M101 (h)
M101 (h)
M102
M102 (h)
etc....


Can someone link me a sample VBA macro that I can use to get this process done? Many thanks!
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Which excel version are you using? If you are using 2007 or later, you could do it by using autofilter and a helper column:

  1. Insert a helper column next to the list column
  2. Apply autofilter over both the columns.
  3. In the list column, Filter for all non - highlighted rows
  4. Insert something random (the number 1, maybe) in the first visible cell of the helper column, copy the cell, select all visible cells in the helper column (select all cells next to the data then use shortcuts – “alt+;”), and paste.
  5. Clear the filter and filter for blank cells in the helper column.
  6. Insert "=(above cell reference)" in the first visible cell of the list column. For example, if first visible cell is A4 insert =A3 in that cell.
  7. Copy this formula, select all visible cells in the column and paste special – formula.
  8. Remove autofilter and you will have your result. You can then delete the helper column.
This is assuming that different highlights were used in the list column. If the highlight is of one colour only, you wouldn’t need the helper column. In that case, skip step 1, in step 3 filter for the highlighted rows, and skip steps 4 and 5, proceeds with other steps as is.
 
Upvote 0
what routine creates the highlight ?
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top