+ Reply to Thread
Results 1 to 2 of 2

Matching First column with the rows

Hybrid View

  1. #1
    Registered User
    Join Date
    09-05-2012
    Location
    Türkiye
    MS-Off Ver
    Excel 2013
    Posts
    80

    Matching First column with the rows

    Hi,everybody

    In each row first cell should match with the same row's rest cells.And the result should be in the page 2 as in the sample.match.xlsx

  2. #2
    Valued Forum Contributor Miroslav R.'s Avatar
    Join Date
    05-16-2013
    Location
    NMnV, Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    479

    Re: Matching First column with the rows

    Hi there,

    maybe Your task can be done in shorter variation, but following code should work:
    Option Explicit
    Sub CopyToNextSheet()
    Dim Sht1, Sht2 As Worksheet
    Dim PosCount As Integer
    Dim Row1 As Integer: Row1 = 1
    Dim Row2 As Integer
    
    Set Sht1 = Sheets("Sayfa1")
    Set Sht2 = Sheets("Sayfa2")
    
    Do Until Sht1.Cells(Row1, 1) = ""
      PosCount = WorksheetFunction.CountA(Sht1.Rows(Row1)) - 1
      Select Case Sht2.Cells(1, 2)
        Case Is = vbNullString
          Row2 = 1
        Case Is >= 1
          Row2 = Sht2.UsedRange.Rows.Count + 1
      End Select
    
      If PosCount > 0 Then
        Sht2.Cells(Row2, 2).Resize(PosCount) = Sht1.Cells(Row1, 1)
        Sht1.Cells(Row1, 2).Resize(, PosCount).Copy
        Sht2.Cells(Row2, 1).PasteSpecial Paste:=xlPasteAll, Transpose:=True
        Else
        Sht2.Cells(Row2, 2) = Sht1.Cells(Row1, 1)
      End If
      Row1 = Row1 + 1
    Loop
    Application.CutCopyMode = False
    End Sub
    Hope it helps
    Regards
    Miroslav R.

    (If You like my solutions, feel free to add reputation.)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Search a column and code all rows with matching value in another column
    By lazypony in forum Excel Formulas & Functions
    Replies: 37
    Last Post: 08-03-2013, 11:23 AM
  2. Concatenate a column based on a column with matching rows
    By excelsior51 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-01-2013, 11:13 AM
  3. Matching values of one column with another rows
    By bimal1stus in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-27-2012, 09:50 AM
  4. Matching multiple rows to column
    By richardwedamins in forum Excel General
    Replies: 12
    Last Post: 04-19-2012, 04:31 PM
  5. Row value concatination for matching rows of another column
    By gunjanbadhey in forum Excel General
    Replies: 1
    Last Post: 12-19-2008, 04:10 AM

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