Results 1 to 5 of 5

Thread: How to copy & paste cell value multiple times using vb or formula in excel

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2016
    Posts
    4

    How to copy & paste cell value multiple times using vb or formula in excel

    Hi i have following column in xl:
    Col : C
    Motor-1
    Motor-2
    Motor-3
    Motor-4
    Motor-5
    Motor-6
    Motor-7
    Motor-8

    Column : D
    Int-1
    Int-2
    Int-3
    Int-4


    I need following op:
    Motor-1\Int-1
    Motor-1\Int-2
    Motor-1\Int-3
    Motor-1\Int-4
    Motor-2\Int-1
    Motor-2\Int-2
    Motor-2\Int-3
    Motor-2\Int-4
    Motor-3\Int-1
    Motor-3\Int-2
    Motor-3\Int-3
    Motor-3\Int-4

    Any help really appreciate
    Excel VB

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: How to copy & paste cell value multiple times using vb or formula in excel

    Thread moved from the 'VB.Net' forum to the 'Office Development/VBA' forum.

  3. #3
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    Re: How to copy & paste cell value multiple times using vb or formula in excel

    This code assumes no headings in columns C and D, and that the data starts in row 1 and there are not blank rows within, and puts the resulting combinations in row E:

    Code:
    Sub combos()
        Dim ws As Worksheet
        Dim c As Integer
        Dim d As Integer
        Dim e As Long
        Dim cNumb As Integer
        Dim dNumb As Integer
        Dim eNumb As Long
        
        Application.ScreenUpdating = False
        
        Set ws = ActiveSheet
        With ws
            cNumb = .Range("c1").End(xlDown).Row
            dNumb = .Range("d1").End(xlDown).Row
            For c = 1 To cNumb
                For d = 1 To dNumb
                    eNumb = eNumb + 1
                    .Range("e" & eNumb).Value = .Range("c" & c).Value & "\" & .Range("d" & d).Value
                Next d
            Next c
        End With
    End Sub

  4. #4

    Thread Starter
    New Member
    Join Date
    Aug 2016
    Posts
    4

    Re: How to copy & paste cell value multiple times using vb or formula in excel

    Thank you. @ vbfbryce
    Working Superfast

  5. #5
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    Re: How to copy & paste cell value multiple times using vb or formula in excel

    Any time!

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width