Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default duplicate a range a specified number of times

How can I copy a range of cells and duplicate it the number of times
specified in a specific cell?

For example cell A1 has 3 as the value. I want to copy A2:B5, and duplicate
it three times (the number in cell A1) and paste side by side in the same
sheet say beginning in cell A7. If cell A1 had a 7 as the value, I want to
copy and duplicate the range 7 times etc.

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default duplicate a range a specified number of times

Sub ABC()
Dim rng As Range, dest As Range
Dim i As Long
Set rng = Range("A2:B5")
Set dest = Range("A7")
For i = 1 To Range("A1").Value
rng.Copy dest
Set dest = dest.Offset(0, rng.Columns.Count)
Next
End Sub

--
Regards,
Tom Ogilvy

"Tbone" wrote:

How can I copy a range of cells and duplicate it the number of times
specified in a specific cell?

For example cell A1 has 3 as the value. I want to copy A2:B5, and duplicate
it three times (the number in cell A1) and paste side by side in the same
sheet say beginning in cell A7. If cell A1 had a 7 as the value, I want to
copy and duplicate the range 7 times etc.

Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default duplicate a range a specified number of times

The code would look something like this:

Dim i As Integer, copyRange As Range
Set copyRange = Range("A2:B5")

For i = 1 To Range("A1")
copyRange.Copy
copyRange.Offset(0, i * copyRange.Columns.Count).PasteSpecial
Next i

On May 4, 3:26 pm, Tbone wrote:
How can I copy a range of cells and duplicate it the number of times
specified in a specific cell?

For example cell A1 has 3 as the value. I want to copy A2:B5, and duplicate
it three times (the number in cell A1) and paste side by side in the same
sheet say beginning in cell A7. If cell A1 had a 7 as the value, I want to
copy and duplicate the range 7 times etc.

Thanks!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding the number of times a word is used in a range of cells Ray Hill Excel Worksheet Functions 8 January 15th 09 07:21 PM
Need to Count the number of times a value occurs within a dt range Gina[_2_] Excel Worksheet Functions 9 July 4th 08 10:19 PM
Duplicate rows a given number of times in Excel? SB Excel Programming 3 February 8th 08 12:07 AM
Duplicate entry "x" number of times gennario Excel Discussion (Misc queries) 1 April 7th 06 11:57 PM
how do I count the number of times a word is repeated in a range? sol Excel Discussion (Misc queries) 3 July 14th 05 01:53 PM


All times are GMT +1. The time now is 05:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"