Copy filled cells in a column to empty cells below - until the next filled cell occures - and so on

TROWKRO

New Member
Joined
Mar 20, 2019
Messages
5
Hi. I have a table with a column A containing filled cells and empty cells. I would like to create a VBA that copies the filled cells to the empty cells below, and when a new cell value occures, this will be copied to the next cells below etc. until there are no more values in column B. Would this be possible?

Thanks at advance.


Column AColumn B
102
empty - should be filled with "10"3
254
empty - should be filled with "25"45
empty - should be filled with "25"67
empty - should be filled with "25"77
empty - should be filled with "25"3
300
empty - should be filled with "30"90
empty - should be filled with "30"12
empty - should be filled with "30"45
empty - should be filled with "30"60
empty - should be filled with "30"1
empty - should be filled with "30"2

<tbody>
</tbody>
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
How about
Code:
Sub Trowkro()
   With Range("A2", Range("B" & Rows.Count).End(xlUp))
      .SpecialCells(xlBlanks).FormulaR1C1 = "=r[-1]c"
      .Value = .Value
   End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
Hi again. Effectively, there is a little problem. The column B should not be filled the same way as with the column A. Column B should not be touched at all.
The proposed code fills the column B the same way as the column A if there is an empty cell or more. Could we tweak the code a little to avoid this?
 
Upvote 0
Oops I missed a bit out, it should be
Code:
Sub Trowkro()
   With Range("A2", Range("B" & Rows.Count).End(xlUp)[COLOR=#ff0000].Offset(, -1)[/COLOR])
      .SpecialCells(xlBlanks).FormulaR1C1 = "=r[-1]c"
      .Value = .Value
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,535
Messages
6,120,090
Members
448,944
Latest member
sharmarick

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