VBA Code to Fill Blank Cells from Bottom to Top in a Dynamic Range

LtCmdrData

Board Regular
Joined
Jan 24, 2018
Messages
58
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a column with numbers and blank cells (column A). The numbers are based off a subtotal row so I need to start at the bottom and work up. I want to repeat the number in the blank cells until it encounters the next subtotal number. The number of blanks will vary and the total number of rows will vary. This is just one part of a bigger macro. I know how to use Go To Special Blanks to select the blank cells but where I have trouble is writing the code to find the last row, move up one, set it equal to the cell beneath and then Ctrl + Enter to enter the formula into all the blanks. This is what I start with:

A B
200022
200002
L438870L438870
200253
200116
200123
199538
L438871L438871
200125
200052
199722
L438873L438873

<colgroup><col><col></colgroup><tbody>
</tbody>


This is what I want it to look like:

A B
L438870200022
L438870200002
L438870L438870
L438871200253
L438871200116
L438871200123
L438871199538
L438871L438871
L438873200125
L438873200052
L438873199722
L438873L438873

<colgroup><col><col></colgroup><tbody>
</tbody>

If it make any difference there will always be an "L" in front of the number I am copying. Can anyone please help me with this situation? Thanks!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
How about
Code:
Sub LtCmdrData()
With Range("A1", Range("A" & Rows.Count).End(xlUp))
   .SpecialCells(xlBlanks).FormulaR1C1 = "=r[1]c"
   .Value = .Value
End With
End Sub
 
Upvote 0
This truly works like magic; so simple yet so effective! Thank you.
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,897
Messages
6,122,151
Members
449,068
Latest member
shiz11713

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