Results 1 to 3 of 3

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

Threaded View

Previous Post Previous Post   Next Post Next Post
  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

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
  •