+ Reply to Thread
Results 1 to 4 of 4

Changes to VBA in this excel.

Hybrid View

  1. #1
    Registered User
    Join Date
    01-24-2014
    Location
    amsterdam
    MS-Off Ver
    Excel 2007
    Posts
    29

    Changes to VBA in this excel.

    I have had an excel with vba code from another person.
    This VBA copies the names from a column to another column a number of times.
    I would like to change it that names are on another worksheet, and the copy has to go to e certain worksheet and places, also names number of times beneath eachother, and number of empty rows.

    Could somebody help me.

    Guido

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Changes to VBA in this excel.

    I can't help you enough with this one, but you get better help if your excel sheet contains the conditions you asked in your question.

    e.g. you don't have names in another sheet.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    01-24-2014
    Location
    amsterdam
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: Changes to VBA in this excel.

    Quote Originally Posted by oeldere View Post
    I can't help you enough with this one, but you get better help if your excel sheet contains the conditions you asked in your question.

    e.g. you don't have names in another sheet.
    On sheet 1 you see at the left a list of names, now i want to have the copies on for instance on sheet 2.
    I need some changes, so i can specify a worksheet where the names are, and i want to specify de destination worksheet on a specific place to start.

    Gaggie

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    24,029

    Re: Changes to VBA in this excel.

    Try this:

    Option Explicit
    
    Sub RepeatRows()
        Dim li As Long
        Dim lRI As Long
        Dim rng As Range
        Dim rngNumberRepeats As Range
        Dim w As Worksheet
        Set w = Sheets("Sheet2")
        
        'Clear previous result
        On Error Resume Next
        w.Cells(1, 5).CurrentRegion.ClearContents
        On Error GoTo 0
        
        'Repeat rows
        Set rngNumberRepeats = Range(Range("A1"), Range("A1").End(xlDown))
        For Each rng In rngNumberRepeats.Cells
            'For li = 1 To rng.Value
            For li = 1 To 4
                lRI = lRI + 1
                w.Cells(lRI, 5).Value = rng.Value
                'Cells(lRI, 6).Value = rng.Offset(0, 1).Value
                'Cells(lRI, 7).Value = rng.Offset(0, 2).Value
            Next li
            lRI = lRI + 13
        Next rng
    End Sub
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ 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