+ Reply to Thread
Results 1 to 6 of 6

Copy a row multiple times based on a call value

Hybrid View

  1. #1
    Registered User
    Join Date
    07-20-2012
    Location
    Pheonix
    MS-Off Ver
    Excel 2007
    Posts
    9

    Copy a row multiple times based on a call value

    Please be patient as I am fairly new to VBA. I seen other code to solve this problem, but can't seem to get it to work, primarily since I have not been able to reasearch down to the Nth degree to understand what it is telling me. I need to get this too work soon and could use a working solution that I could then backtrack to gain understanding based on my data instead of generic expressions and variables.



    Workshett 1 = Current Mill Shedule
    Worksheet 2 = Sheet2
    I have a series of rows on Worksheet 1, each row has value in column "AE". I need to copy the row from Worksheet 1 'X' times equal the value in "AE" to Worksheet 2.
    I need to to it for each row on Worksheet 1.
    The number of rows on Worksheet 1 varies each time I will need to run the Macro.

    Any assistance would be greatly appreciated.


    Thanks in advance.

  2. #2
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    860

    Re: Copy a row multiple times based on a call value

    Without example.

    Sub hsv()
     Dim i As Long, cl As Range
      Sheets(2).UsedRange.ClearContents
        Application.ScreenUpdating = False
         With Sheets(1)
     For Each cl In .Range("AE1:AE" & .Cells(Rows.Count, 31).End(xlUp).Row)
         For i = 1 To cl.Value
           Sheets(2).Cells(Rows.Count, 1).End(xlUp).Offset(1).Resize(, 30) = .Cells(cl.Row, 1).Resize(, 30).Value
         Next i
       Next cl
      End With
    End Sub
    Harry.

  3. #3
    Registered User
    Join Date
    07-20-2012
    Location
    Pheonix
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Copy a row multiple times based on a call value

    Thanks for the Quick reply.

    Marco Example - 072112.xlsx

    This is what I am working with.(less what I can't share)

    I tried what you gave me from Current Mill Schedule "A2" and it appears all it did was clear contents of Current Mill Schedule. Do I need to change something before running?

  4. #4
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    860

    Re: Copy a row multiple times based on a call value

    In module 1.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    07-20-2012
    Location
    Pheonix
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Copy a row multiple times based on a call value

    HSV,
    THe file you sent back works great, but when I try to move it into my project it does not. What am I missing?
    Thanks in advance.

    Woodchuck75

  6. #6
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    860

    Re: Copy a row multiple times based on a call value

    Let me guess:

    Sheetnumber.
    Columnnumber.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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