Results 1 to 3 of 3

Thread: Excel VBA Macro To Repeat Records Based On User Value In InputBox

  1. #1
    Junior Member
    Join Date
    Feb 2016
    Posts
    1
    Rep Power
    0

    Excel VBA Macro To Repeat Records Based On User Value In InputBox

    Is there a way to Modify this Macro to read a list of Number in Sheet 2, by Cell A1 then A2, etc (loop) for example the table below would reflect what is in Sheet 2.Then take that number in Sheet 2 A1 and place it in Column U with all the Data and then copy and Duplicate "A1:"U189" beside me having to put the total number or repetitions in the Input Box. So now basically the Macro is now labeling all that is being Copied by Sheet 2 A1, A2,. So in my example 101 would have 189 lines labeled as 101 and 102 will have 189 labeled as 102


    Code:
    Dim rng As Range
    Dim i As Long
    
    Set rng = Range("A1:T189")
    For i = 1 To InputBox("Enter repetitions")
    rng.Copy rng.Offset(rng.Rows.Count * i)
    Next i

    101
    102
    103
    104
    105
    Last edited by Excel Fox; 02-12-2016 at 04:34 PM. Reason: Code Tags added

  2. #2
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    13
    Dear gclifton,

    Welcome to the forum. Although here it's not against forum rules most helpers do not appreciate crossposting.(putting your question in multiple forums)
    Since all helpers here do this in their spare time and free of charge it's common policy to provide a link(s) to the other forum where you put your question so they can check progress and don't waste their time on solving a question which might already be answered elsewhere.
    Is your question answered elsewhere post a message here saying so and mark your thread as solved.
    If you do not comply to this next time you crosspost without a link your thread will be closed.

    VBA Input Box

  3. #3
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    gclifton, please use VBA code tags to wrap your code.

    On your question, can you attach a sample workbook with pre and post examples. That will make it easy for a developer to create a macro for you.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

Similar Threads

  1. Macro to delete Non Duplicate Records
    By Howardc in forum Excel Help
    Replies: 2
    Last Post: 10-17-2013, 08:13 PM
  2. Insert Or Delete Columns Based On User Input
    By HDMI in forum Excel Help
    Replies: 4
    Last Post: 06-21-2013, 03:00 AM
  3. Replies: 4
    Last Post: 06-01-2013, 02:22 PM
  4. How to track user activity using a macro?
    By Rajesh Kr Joshi in forum Excel Help
    Replies: 4
    Last Post: 08-10-2012, 06:50 PM
  5. Replies: 0
    Last Post: 02-27-2012, 01:07 AM

Posting Permissions

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