+ Reply to Thread
Results 1 to 4 of 4

Copy and Paste names using a variable for the number of times

Hybrid View

miles44 Copy and Paste names using a... 05-04-2015, 02:50 PM
simarui Re: Copy and Paste names... 05-04-2015, 02:55 PM
PCI Re: Copy and Paste names... 05-04-2015, 03:00 PM
miles44 Re: Copy and Paste names... 05-04-2015, 03:13 PM
  1. #1
    Forum Contributor
    Join Date
    05-04-2015
    Location
    Atlanta GA
    MS-Off Ver
    2010
    Posts
    108

    Copy and Paste names using a variable for the number of times

    I have a list of names beginning in A1. There's a corresponding list of numbers in B1.

    Mike 5
    Sam 6
    Wiley 7
    Brian 3

    I would like the 3rd column to be so that there would be as many names as there are the number in column 2.
    Mike
    Mike
    Mike
    Mike
    Mike
    Sam
    Sam
    Sam
    Sam
    Sam
    Sam
    Wiley
    Wiley
    Wiley
    Wiley
    Wiley
    Wiley
    Wiley
    Brian
    Brian
    Brian

    Thanks for any help

  2. #2
    Valued Forum Contributor
    Join Date
    01-10-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    651

    Re: Copy and Paste names using a variable for the number of times

    are you familiar with vba?

    this oughta do the trick:

    Private Sub nameslist()
    Dim lr As Long
    Dim rng As Range
    Dim nlr As Long
    lr = Range("A" & Rows.Count).End(xlUp).row
    nlr = 1
    For Each rng In Range("A1:A" & lr)
        For i = 1 To rng.Offset(0, 1)
        Range("C" & nlr) = rng
        nlr = nlr + 1
        Next i
    Next rng
    End Sub
    Hope I could help - if your post has been solved don't forget to mark it as such.

    Clicking the * below is a great way to say thanks!

    "Drowning in 10 feet of water isn?t any different than drowning in a million feet. And if you can swim, it doesn?t matter how deep the ocean is. At some level, once you realize you?re in water that?s too deep to stand, you have to have a very different approach," - Joi Ito

  3. #3
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Copy and Paste names using a variable for the number of times

    Try
    Option Explicit
    
    Sub Macro3()
    Dim LR As Long, I As Long
        LR = 0
        For I = 1 To Range("A" & Rows.Count).End(xlUp).Row
            Cells(LR + 1, "C").Resize(Cells(I, "B"), 1) = Cells(I, "A")
            LR = Range("C" & Rows.Count).End(xlUp).Row
        Next
    End Sub
    - Battle without fear gives no glory - Just try

  4. #4
    Forum Contributor
    Join Date
    05-04-2015
    Location
    Atlanta GA
    MS-Off Ver
    2010
    Posts
    108

    Re: Copy and Paste names using a variable for the number of times

    They both worked perfectly!! Thanks so much. This will save me a TON of work.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Copy/paste variable wbk names
    By Wheelie686 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-19-2015, 12:35 PM
  2. Copy and Paste a defined number of times...
    By ccxc007 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-15-2012, 02:10 AM
  3. [SOLVED] Copy one value and paste it x number of times
    By jcb in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-12-2012, 04:52 PM
  4. VBA; copy paste number of times based on cell value
    By photopidge in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-25-2011, 03:17 AM
  5. Copy then paste/insert X number of times
    By Steve6386 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-04-2010, 04:53 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1