Fill Down Blank Cells in Table via VBA

jski21

Board Regular
Joined
Jan 2, 2019
Messages
155
Office Version
  1. 2016
Platform
  1. Windows
Good Day Mr. Excel Team,

Ran across a lousy download from a central source (govt) I'll need on a regular basis that does not follow basic database courtesy. I'm seeking to have a snippet of code that would work its way through a table, locating a blank cell, and then copying down the data immediately above to all the blank cells below. The spreadsheet can get rather voluminous, hence the ask for some expertise. So far, I'm only seeing instances of this in Column 1 and Column 7.


Column 1Column 2Column 3Column 4Column 5Column 6Column 7Column 8Column 9Column 10Column 11Column 12Column 13Column 14Column 15
1656291221/14/1998Conv-Sum01/14/19981/14/1998ABCPDQ12341982EN123456789123456789ABCD$32,371,000.00
1656301221/14/1998Conv-Sum01/14/19981/14/1998ABCPDQ12341989EN123456789123456789ABCD$23,796,000.00
1656311221/14/1998Conv-Sum01/14/19981/14/1998ABCPDQ12341990EN123456789123456789ABCD$22,691,000.00
1656321221/14/1998Conv-Sum01/14/19981/14/1998ABCPDQ12341991EN123456789123456789ABCD$25,108,000.00
1656331221/14/1998Conv-Sum01/14/19981/14/1998ABCPDQ12341992EN123456789123456789ABCD$26,382,000.00
1656341221/14/1998Conv-Sum01/14/19981/14/1998ABCPDQ12341993EN123456789123456789ABCD$30,251,000.00
1656351221/14/1998Conv-Sum01/14/19981/14/1998ABCPDQ12341994EN123456789123456789ABCD$33,571,000.00
1656361221/14/1998Conv-Sum01/14/19981/14/1998ABCPDQ12341995EN123456789123456789ABCD$33,604,000.00
1656371221/14/1998Conv-Sum01/14/19981/14/1998ABCPDQ12341996EN123456789123456789ABCD$32,571,000.00
1656381221/14/1998Conv-Sum01/14/19981/14/1998ABCPDQ12341997EN123456789123456789ABCD$6,036,449.72
1656401151/14/1998Conv-Sum01/14/19981/14/1998ABCPDQ12341992EN123456789123456789EFGH$42,557.00
1656411161/14/1998Conv-Sum01/14/19981/14/1998ABCPDQ12341992EN123456789123456789EFGH$11,800.00
1656421171/14/1998Conv-Sum01/14/19981/14/1998ABCPDQ12341992EN123456789123456789EFGH$29,500.00
165981115081/14/1998Conv-Sum01/14/19981/14/1998ABCPDQ12341993EN123456789123456789EFGH$11.00
165982116701/14/1998Revised1/14/1998ABCPDQ12341993EN123456789123456789EFGH$17,005.00
2117310/4/2001Conv-Sum1/14/1998ABCPDQ12341993EN123456789123456789EFGH$0.00
3167010/4/2001Revised1/14/1998ABCPDQ12341993EN123456789123456789EFGH$17,005.00
4117310/4/2001Conv-Sum1/14/1998ABCPDQ12341993EN123456789123456789EFGH$17,005.00
5167010/4/2001Conv-Sum1/14/1998ABCPDQ12341993EN123456789123456789EFGH$0.00

Many thanks in advance for the review, consideration, and guidance.

jski
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Try this:

VBA Code:
Sub filldown()
  Dim lr As Long, lc As Long
 
  lr = Cells.Find("*", , xlValues, xlPart, xlByRows, xlPrevious).Row
  lc = Cells(1, Columns.Count).End(1).Column
  With Range("A1", Cells(lr, lc))
    .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
    .Value = .Value
  End With
End Sub

You may need to adjust the format of the column so that the new values take it into account.
 
Upvote 0
Solution
Try this:

VBA Code:
Sub filldown()
  Dim lr As Long, lc As Long
 
  lr = Cells.Find("*", , xlValues, xlPart, xlByRows, xlPrevious).Row
  lc = Cells(1, Columns.Count).End(1).Column
  With Range("A1", Cells(lr, lc))
    .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
    .Value = .Value
  End With
End Sub

You may need to adjust the format of the column so that the new values take it into account.
Beautiful, accurate, and quick. Thank you DanteAmor!
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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