Duplicate Cells dependant on a value being placed

mecheet

Board Regular
Joined
Apr 21, 2010
Messages
117
Hi,

If i have a cell say A2, that so a number is placed in there, say 2.

then a range of data is copied and pasted below, so duplicate information is shown underneath. If the value in A2 is 3, then would need the data copying twice down the page.

A2 = 3

so the range in A10:F20, needs to be copied and pasted underneath twice, so in cells A21 and A41.

If this value in A2 = 4 it would need to be pasted again.

If further examples or information is needed please let me know.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Try:
Code:
Sub CopyMeYou ()
Application.ScreenUpdating = False
Dim DupQty As Integer
Dim RangeToCopy As Range
Set RangeToCopy = Range("A10:F20")
If Range("A2") > 0 Then
    DupQty = Application.RoundUp(Range("A2"), 0)
    For DupQty = DupQty To 2 Step -1
        RangeToCopy.Copy
        Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteAll
    Next DupQty
End If
Application.ScreenUpdating = True  
End Sub
 
Upvote 0
thanks i have changed the code slightly to fit my exact cells but when i place 3 in cell Q14 it only copies the data once.

Code:
Sub CopyMeYou()
Application.ScreenUpdating = False
Dim DupQty As Integer
Dim RangeToCopy As Range
Set RangeToCopy = Range("A21:V57")
If Range("Q14") > 0 Then
    DupQty = Application.RoundUp(Range("Q14"), 0)
    For DupQty = DupQty To 2 Step -1
        RangeToCopy.Copy
        Range("A" & Rows.Count).End(xlUp).Offset(58, 0).PasteSpecial xlPasteAll
    Next DupQty
End If
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Just re-tested my code and your adjusted code and when I use 3 it copies it twice as expected
 
Upvote 0
thanks for that,

can you please post your adapted code as im still getting it to only copy down once.
 
Upvote 0
i think i have worked out why mine isnt working as expected, is because i need the data that is in cells A1:V20 to stay no matter what value is placed in cell Q14.

Can anyone help to adapt the code to incorporate this?
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,822
Members
452,946
Latest member
JoseDavid

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