Run Loop from bottom to top of range

Zshadowman

New Member
Joined
Oct 19, 2005
Messages
4
Hello,

I just can not seem to get this right. I'm on Excel 2003 and have a macro to fill in blank cells with the value from the cell above it. Now I need a macro to undo this. There may be 1 or 2 cells or as many as 12 cells in sequence that were filled with the same value (ie: B12,B13,B14,B15,B16, are filled from B11 value, B18,B19 are filled from B17 value, B21,B22,B23 are filled from B20 value, and so on) . I need to leave the top/beginning value and return the filled cells to blanks.

If I just reverse the fill macro it skips everyother cell because it "blanks" the first duplicate and then when it moves down to next cell (which reads equal to the "fill" cell source which is now 2 rows up) but the macro is comparing to the cell it just set to blank.

Here is original "fill" macro. Please help me figure out the correct undo macro that will leave only the top/beginning value in each random group.

Thanks a bunch... here is macro...

Sub FillCellfromAboveCell()

For Each Cell In Range("B9:B200")
If Cell.Value = "Stop" Then Exit Sub
If UCase(Cell.Value) = "" Then Cell.Value = Cell.Offset(-1, 0)
Next Cell
End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi,

Does this do what you're after?

Code:
Sub Reverse()

Dim c As Integer

For c = 200 To 9 Step -1

If Cells(c, 2) = Cells(c - 1, 2) Then Cells(c, 2).Clear

Next c

End Sub

Dom
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

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