I have a column with some values that are separated by different number of empty cells. How can I copy each of these value to the n empty cells below them? In my case n = 3 is no bigger than the minimum number of empty space between them.
Thanks for your reply. I know this methods, but it will autofill the value to all the empty cells below it. Like AAAAAAAAABBBBCCCC. I would like each value copied only 3 times, something like AAAA-----BBBBCCCC, -stands for empty cells.
Assuming that your data starts in A2 then maybe...
VBA Code:
Sub Ixcel()
Dim i As Long
For i = Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
If Cells(i, "A") <> "" Then Cells(i, "A").Resize(4).Value = Cells(i, "A").Value
Next
End Sub
Edit:
Or a tiny bit better
VBA Code:
Sub Ixcel2()
Dim i As Long
For i = Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
If Cells(i, "A") <> "" And WorksheetFunction.CountA(Cells(i, "A").Offset(1).Resize(3)) = 0 Then Cells(i, "A").Resize(4).Value = Cells(i, "A").Value
Next
End Sub
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.