+ Reply to Thread
Results 1 to 3 of 3

Copy multiple columns in a loop

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Copy multiple columns in a loop

    On "Sheet 2" there are 24 names in row 45 (more will be added later). Below each name are a maximum of 30 stock symbols. For the first name, I need to copy the symbols and paste them into A6:A35. Data will then populate in S36:AI36. Copy S36:AI36 to "Sheet 1" B3:R3.

    Next go back to "Sheet 2" clear the range A6:A35 and repeat the same process for the 2nd, 3rd, 4th name ect.
    Attached Files Attached Files
    Last edited by rhudgins; 07-08-2010 at 07:45 PM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Copy multiple columns in a loop

    Hi

    see how this goes.
    Sub aaa()
      Dim DataSH As Worksheet, OutSH As Worksheet
      Dim NameRng As Range
      Set DataSH = Sheets("Sheet2")
      Set OutSH = Sheets("Sheet1")
      With DataSH
        Set NameRng = .Range(.Range("S45"), .Range("S45").End(xlToRight))
      End With
      
      For Each ce In NameRng
        outrow = WorksheetFunction.Match(ce.Value, OutSH.Range("A:A"), 0)
        DataSH.Range("A6:A35").Value = ce.Offset(1, 0).Resize(30, 1).Value
        OutSH.Cells(outrow, 2).Resize(1, 17).Value = DataSH.Range("S36:AI36").Value
      Next ce
      
    End Sub
    rylo

  3. #3
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Re: Copy multiple columns in a loop

    Thanks this is exactly what I needed!! Thanks for your help

+ 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