Automate select, copy, paste with loop

canippon

New Member
Joined
Apr 12, 2021
Messages
5
Office Version
  1. 2010
  2. 2007
Platform
  1. Windows
Hello Members and Experts,
I need to record a list of 80 bowlers their scores for analysis and hope to obtain your help.

The spredsheet contains 4 columns:
column A: Member's Number
column B: Member's Name
column C: Rank
column D: Score

Not all bowlers play exactly same number of game; some play more, some play less, so each bowler will occupy different number of rows to represent each score. Eg. the 1st bowler plays 4 games, 2nd bowler plays 6 games, and the 3rd bowler plays 3 games, and so forth. Thus column A and B, starting from Row 2 for the first bowler, always contain empty rows until the next bowler appears. I then have to copy each bowler's number (column A) and name (column B) and paste that to every single row.

With my very limited knowledge on VBA/Macro I can only create below one that can accomplish the first bowler, but without being able to repeat the process to all others.


Sub testFill()

' testFill Macro
'
Range("A2:B2").Select
Selection.Copy
Range(Selection, Selection.End(xlDown).Offset(-1, 0)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.End(xlDown).Select

End Sub


I realize some loop process with the likes of Do...Until, Do...While, For....Next but just don't know the appropriate syntax.

Thanks very much in advance.
 

Attachments

  • bowling score.png
    bowling score.png
    17.1 KB · Views: 8

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hi & welcome to MrExcel.
How about
VBA Code:
Sub canippon()
   With Range("A2:B" & Range("C" & Rows.Count).End(xlUp).Row)
      .SpecialCells(xlBlanks).FormulaR1C1 = "=r[-1]c"
      .Value = .Value
   End With
End Sub
 
Upvote 0
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Automate select, copy, paste command with VBA
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Automate select, copy, paste command with VBA
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
I am sorry for breaking any rules, if any, as it's not my intention to do so. Will pay attention to that moving forward.
 
Upvote 0
Hi & welcome to MrExcel.
How about
VBA Code:
Sub canippon()
   With Range("A2:B" & Range("C" & Rows.Count).End(xlUp).Row)
      .SpecialCells(xlBlanks).FormulaR1C1 = "=r[-1]c"
      .Value = .Value
   End With
End Sub
Thank you so much, this works.
I thought the use of Loop syntax is required but what you propose is completely different.

Just to know as well.....in case column C is left blank for some other reason so I should change the syntax by replacing "C" with the column contains data. Am I correct?
 
Upvote 0
Just to know as well.....in case column C is left blank for some other reason so I should change the syntax by replacing "C" with the column contains data. Am I correct?
That's right :)
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,535
Messages
6,114,194
Members
448,554
Latest member
Gleisner2

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