简体   繁体   中英

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

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!

I'm going to assume that 'M101' for example is not a cell but rather a value in a column.
Some googling of what my pseudocode solution below will set you on the right track if I have assumed correctly...

for (column):  
if (currentCell is highlighted) then  
currentCell.value = currentCell.one_up.value

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM