VBA to fill missing Cells...

Matty

Well-known Member
Joined
Feb 17, 2007
Messages
3,710
Hello All,

Given the following data set:

Excel Workbook
AB
1DataADataB
2SomethingA15
3SomethingA47
4SomethingA48
5SomethingA26
6SomethingA52
7SomethingA45
8SomethingB36
9SomethingB89
10SomethingB72
11SomethingB14
122
1319
Sheet1
Excel 2003


What's the best way of filling Cells A12 and A13 with the value in the next populated Cell up, i.e. "SomethingB"?

I'm aware of the F5 > Blanks > Ctrl + Enter etc. method, but I'm looking for code to do this as it'll form part of a larger macro.

Thanks in advance.

Matty
 

Some videos you may like

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

Code:
Sub FillBl()
Dim LR As Long
LR = Range("B" & Rows.Count).End(xlUp).Row
With Range("A1:A" & LR)
    .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
    .Value = .Value
End With
End Sub
 

Matty

Well-known Member
Joined
Feb 17, 2007
Messages
3,710
Cheers Peter.

I will eventually get my head around all of these techniques!

Regards,

Matty
 

Watch MrExcel Video

Forum statistics

Threads
1,128,089
Messages
5,628,607
Members
416,327
Latest member
Chimay

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
Top