Consulting

Results 1 to 5 of 5

Thread: spread repated cells

  1. #1
    VBAX Regular
    Joined
    Jan 2011
    Posts
    55
    Location

    spread repated cells

    Dear forum,

    I have blocking point, for which I not founding solution,

    I have huge table in which I need to repeat some line with a given number, please refer to the attached xls file,

    the opposite action is too simple, but what is the solution for my case

    br,
    amrane
    Attached Files Attached Files

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,072
    Location
    =Rept(text,number)
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    if you need a vba solution, try;

    Sub vbax_57711_copy_cells_values_n_times()
    
        Dim i As Long
        
        With Worksheets("Sheet1") 'change Sheet1 to suit
            For i = 2 To .Range("A" & .Rows.Count).End(xlUp).Row
                .Range("E" & .Rows.Count).End(xlUp).Offset(1).Resize(.Range("B" & i)).Value = .Range("A" & i).Value
            Next
        End With
    
    End Sub
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  4. #4
    VBAX Regular
    Joined
    Jan 2011
    Posts
    55
    Location

    Thumbs up

    Dear Mancubus,

    this professional solution, that's great,
    thank you a lot,

    Amrane,

  5. #5
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,730
    Location
    Option Explicit
    Sub Repeats()
        Dim rControls As Range, rControl As Range
        Dim iOut As Long, iNum As Long
        
        Application.ScreenUpdating = False
        
        'A2 to end of data, 2 columns
        Set rControls = Range(ActiveSheet.Range("A2"), ActiveSheet.Range("A2").End(xlDown)).Resize(, 2)
        
        iOut = 2
        For Each rControl In rControls.Rows
            For iNum = 1 To rControl.Cells(1, 2).Value
                'starts in row 2 column 5
                ActiveSheet.Cells(iOut, 5).Value = rControl.Cells(1, 1).Value
                iOut = iOut + 1
            Next iNum
        Next
        Application.ScreenUpdating = True
    End Sub
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

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