Looping through column B , Finding Value In Column A & Copy Paste Specific Number Of Times

benntw

Board Regular
Joined
Feb 17, 2014
Messages
222
Office Version
  1. 365
Platform
  1. Windows
I have a report that I built in Primavera grouping by a code in column A. Column B has values from 7 categories for every code. My code value starts in column A Row 3 and my 7 categories start in column B Row 3. I have multiple columns to the right, but column B is my solid range of data. What I want to do is loop through column B for excel to know the last line of data. I need to run down column A and copy the code and paste it 6 more times underneath it all the way down until the last range of data in column B. Here is an example of my columns data.

Column A Row 3 Column B Row 3

Team 1 Budgeted Units
Actual Units
Remaining Early Units
Cum Budgeted Units
Cum Actual Units
Cum Remaining Early Units
Cum At Completion Units
Team 2 Budgeted Units
Actual Units
Remaining Early Units
Cum Budgeted Units
Cum Actual Units
Cum Remaining Early Units
Cum At Completion Units

This continues the same grouping until my last team in the grouping. I can manually fill out the 6 empty cells between the Teams, but a VBA code to do this would be much quicker. All my data to the right of column B is a horizontal date range. A pivot table would not be the right choice for this. Hopefully someone can help me out with this. Hope this made sense. Thank you.
 
Last edited:

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
perhaps like this
Code:
Sub testing()
    Dim i As Long
With Sheets("Sheet1")
    For i = 3 To .Cells(Rows.Count, "B").End(xlUp).Row Step 7
        .Range("A" & i).Resize(7) = .Range("A" & i)
    Next i
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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