variable rows to be copied

T

tpeter

I have multiple tabs in one spreadsheet. When the user enters a tab I have a
user form that asks for how many rows they would like to have. This could
range from 1-250. The textbox info is placed in cell m2. I don't know how to
copy range c15:k15 the number of times it takes to meet the users request. An
example would be if they entered 5 in the textbox, select range c15:k15 and
copy in down four times. Any help would be great.

Tim Peter
 
J

JLGWhiz

Your description is not very clear. To expand Range("C15:K15") to five
rows:

rng = Range("C15:K15")
rng.Resize(5, 9)

would increase the range size by five rows.
 
R

Rick Rothstein

Give this a try...

HowManyTimes = 5
Range("C15:K15").Resize(HowManyTimes).Value = Range("C15:K15").Value
 
P

Patrick Molloy

try something like this:

Option Explicit
Sub Main()
Dim qrows As Long
qrows = InputBox("How many rows")
If qrows > 0 Then
Range("C15:k15").Copy
Range("C16").Resize(qrows - 1).PasteSpecial xlPasteAll
Application.CutCopyMode = False
End If


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top