vba to copy column data in stages

jeffdolton

Board Regular
Joined
Dec 21, 2020
Messages
100
Office Version
  1. 2010
Platform
  1. Windows
Hi, I'm looking for some code please.

I have a workbook that consists of a food and drink table downloaded from an EPOS system. Here is a OneDrive link to my file Test file Produc Library.xlsx.

I want to be able to fill in the gaps in column A by copying a last cell in the list to all the blank cells immediately below then move to the next item and copy that down and so on. So to be clear cell A12 to be copied to cell A41, then cell A42 to be copied to A56 etc. Please note that the length of this table isn't finite and there could be blanks to fill in below the last 'name' entry. That would depend if there are any options in columns B,C and D.

Thanks for your help.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
How about
VBA Code:
Sub jeffdolton()
   With Range("A2", Range("A" & Rows.Count).End(xlUp))
      .SpecialCells(xlBlanks).FormulaR1C1 = "=r[-1]c"
      .Value = .Value
   End With
End Sub
 
Upvote 0
Hi, I'm looking for some code please.

I have a workbook that consists of a food and drink table downloaded from an EPOS system. Here is a OneDrive link to my file Test file Produc Library.xlsx.

I want to be able to fill in the gaps in column A by copying a last cell in the list to all the blank cells immediately below then move to the next item and copy that down and so on. So to be clear cell A12 to be copied to cell A41, then cell A42 to be copied to A56 etc. Please note that the length of this table isn't finite and there could be blanks to fill in below the last 'name' entry. That would depend if there are any options in columns B,C and D.

Thanks for your help.
Many thanks. It worked for all items except the bottom item 'Youth T Shirt'. I added some additional options in Column B below M 7/8 and these were not populated with the name when the code was run.
 
Upvote 0
Ok, how about
VBA Code:
Sub jeffdalton()
   With Range("A2:A" & Range("B" & Rows.Count).End(xlUp).Row)
      .SpecialCells(xlBlanks).FormulaR1C1 = "=r[-1]c"
      .Value = .Value
   End With
End Sub
 
Upvote 0
Solution
Ok, how about
VBA Code:
Sub jeffdalton()
   With Range("A2:A" & Range("B" & Rows.Count).End(xlUp).Row)
      .SpecialCells(xlBlanks).FormulaR1C1 = "=r[-1]c"
      .Value = .Value
   End With
End Sub
It worked a treat, thanks very much.
 
Upvote 0
You're welcome & thanks for the feedback.
For future reference when you Mark as Solution, you need to select the post that helped the most, not your post saying it works. I have changed it for you this time.
 
Upvote 0

Forum statistics

Threads
1,215,217
Messages
6,123,675
Members
449,116
Latest member
HypnoFant

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