Fill blank rows with cell above...

JRenn

New Member
Joined
Nov 3, 2017
Messages
5
I'm trying to create a macro that will, for a selected range (5000 rows), fill a cell with the contents of the cell above if the cell to the right is not empty/blank.

Your assistance appreciated.

Regards
 

Some videos you may like

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

FracinDean

Board Regular
Joined
Jul 11, 2011
Messages
65
Name the range that you want to test the cells beside it. Example, cells A1:A5000 are named myRange, and some of the cells B1:B5000 are blank. The following code worked for me when I tested it:

Code:
Dim lastThing As Variant
Range("myRange").Select
lastThing = ""
For Each thing In Selection
       If Cells(thing.Row, thing.Column+1).Value <> "" Then thing.Value = lastThing
       lastThing = thing.Value
Next
 

Forum statistics

Threads
1,089,201
Messages
5,406,810
Members
403,106
Latest member
AliO

This Week's Hot Topics

Top