VBA Code Needs Revamping

Topher177

New Member
Joined
Nov 24, 2015
Messages
4
Hello, I have this code behind my worksheet that is really slow and sluggish. I know there must be an easier way because the concept behind the code itself is not all too complex. The purpose of this code is to loop through column BO and paste each value 7 times. After a value is pasted, the code should move down to the next row. Each value should be pasted in column BW in the next empty row. Any help would be greatly appreciated!

Code:
Sub CopyNames ()
Dim x As Long, numberOfTimes As Long 'number of times to "copy"
Dim rngToCopy As Range
Dim rngToPaste As Range
Set pasteSheet = Worksheets("Report")


'## Define the range you want to copy:
Set rngToCopy = Range("BO10")


'## Get the number "X" from cell D1:
numberOfTimes = Range("BO7").Value


w = 1


For Each r In Range("BO9", Range("BO" & Rows.Count).End(xlUp))


rngToCopy.copy
    
For x = 1 To numberOfTimes


    '# Copy and Paste


    pasteSheet.Cells(Rows.Count, "BW").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues


Next


rngToCopy = rngToCopy.Offset(w, 0)
w = w + 1


Next
End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
22123first 10 rows are previously entered data45this cell equalled 10 before the macro ran
33234
44345
55456
66567
678
789
987
876
765
22macro
22
22rownum = Cells(1, 10)
22 For j = 1 To 6
22 For k = 1 To 7
22 rownum = rownum + 1
22 Cells(rownum, 5) = Cells(j, 1)
33 Next k
33 Next j
33End Sub
33
33
33
33
44
44
44
44
44
44
44
55
55
55
55
55
55
55
66
66
66
66
66
66
66

<colgroup><col span="14"></colgroup><tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,216,117
Messages
6,128,935
Members
449,480
Latest member
yesitisasport

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