Macro to copy down specific number of rows

  • Thread starter Thread starter JA
  • Start date Start date
J

JA

Cell A1 contains Username and cell B1 contains a number
indicating how many times the names should be replicated
in the database.

Please help with a macro to do this.
 
Cell A1 contains Username and cell B1 contains a number
indicating how many times the names should be replicated
in the database.

try this:

Range("A2:A" & Range("B1").Value).Value = Range("A1").Value

--
Mit freundlichen Grüssen

Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)
 
Cell A1 contains Username and cell B1 contains a number
I forgot a value:
Range("A2:A" & Range("B1").Value + 1).Value = Range("A1").Value

--
Mit freundlichen Grüssen

Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)
 
Using Resize might be clearer in terms of intent. Just offered for
consideration.

Range("A2").Resize(Range("B1").Value ,1).Value = Range("A1").Value
 
Hi Tom,

Tom said:
Using Resize might be clearer in terms of intent. Just offered for
consideration.

Range("A2").Resize(Range("B1").Value ,1).Value = Range("A1").Value

thus it goes naturally also :-)

--
Mit freundlichen Grüssen

Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)
 

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

Back
Top