+ Reply to Thread
Results 1 to 4 of 4

Updating a macro so it repeats the same process to 3 columns

  1. #1
    Registered User
    Join Date
    05-25-2004
    Posts
    30

    Updating a macro so it repeats the same process to 3 columns

    I need to duplicate a set of three numbers multiple times throughout my workday.
    I found the macro below that works great for one number. How would I adjust this so it is applied to three numbers?

    Currently, the macro duplicates what I have in column A as follows.
    A B
    1059 1059
    1059
    1059
    etc.


    Looking for this
    A B C D E F
    1059 2001 203 1059 2001 203
    1059 2001 203
    1059 2001 203
    etc. etc. etc.


    Current macro

    Sub Code_One_thousand()
    Dim NumCopies As Long, Lastrow As Long
    Dim c As Range, MyRange As Range
    Dim LastRow2 As Long
    'Change this to the amount of time to copy
    NumCopies = 1000
    LastRow2 = 1
    Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
    Set MyRange = Range("A1:A" & Lastrow)
    For Each c In MyRange
    Cells(LastRow2, "B").Resize(NumCopies) = c.Value
    LastRow2 = LastRow2 + NumCopies
    Next
    End Sub

    Many thanks,
    Chris
    Last edited by repke; 04-19-2018 at 07:33 PM.

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,647

    Re: Updating a macro so it repeats the same process to 3 columns

    Not sure what you are asking.
    See if this is what you are trying to achieve.
    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Registered User
    Join Date
    05-25-2004
    Posts
    30

    Re: Updating a macro so it repeats the same process to 3 columns

    Attachment 570659

    Sorry sktneer, the formatting was wiped out in my original post so I've attached a picture.

    What I'm trying to do is enter 3 values in columns A, B, and C. The macro will then duplicate each of those values 1,000 times in column D, E, and F.

    A copied 1,000 to D
    B copied 1,000 to E
    C copied 1,000 to F.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,464

    Re: Updating a macro so it repeats the same process to 3 columns

    The link to your attachment doesn't work.

    Do you want what you have in A-C copied to next set of columns for 1000 times?
    Please Login or Register  to view this content.

+ 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. Macro for updating 2 columns timestamp
    By JorgeP in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-15-2016, 11:00 AM
  2. Excel Macro for updating different columns
    By Garshan300 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-17-2015, 11:22 AM
  3. Updating code hassle - automate the process
    By saechaoc in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-24-2015, 04:31 PM
  4. need macro for auto updating columns
    By jaceyjay in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-21-2014, 06:54 AM
  5. Replies: 6
    Last Post: 12-09-2012, 09:00 PM
  6. Possible Macro? Process repeats itself
    By Wheelie686 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-28-2012, 07:28 PM
  7. Formulae for: 4 most repeats,4 least repeats in a series of numbers
    By Sedge in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-02-2010, 04:56 AM

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