+ Reply to Thread
Results 1 to 4 of 4

To copy data from sheet-1 to sheet-2

Hybrid View

  1. #1
    Registered User
    Join Date
    03-17-2016
    Location
    chennai,india
    MS-Off Ver
    2013
    Posts
    11

    To copy data from sheet-1 to sheet-2

    I have data like below in sheet -1

    a.jpg


    And I need the above data to be copied in sheet-2 like

    b.jpg

    I am very new to the macro,Could anyone help me in this...
    Last edited by madhavaraja; 02-16-2019 at 11:08 AM.

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: To copy data from sheet-1 to sheet-2

    Try this code
    Sub Test()
        Dim a, v, i As Long, c As Integer
    
        c = 1   'First Column In Sheet2 (Change To Suit)
        a = Worksheets("Sheet1").Range("A2:B" & Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row).Value
    
        With CreateObject("Scripting.Dictionary")
            .CompareMode = 1
            For i = LBound(a) To UBound(a)
                If .Exists(a(i, 1)) Then
                    .Item(a(i, 1)) = .Item(a(i, 1)) & Chr(2) & a(i, 2)
                Else
                    .Item(a(i, 1)) = a(i, 1) & Chr(2) & a(i, 2)
                End If
            Next i
    
            For Each v In .Items
                Worksheets("Sheet2").Cells(1, c).Resize(UBound(Split(v, Chr(2))) + 1).Value = Application.Transpose(Split(v, Chr(2)))
                c = c + 1
            Next v
        End With
    End Sub
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Registered User
    Join Date
    03-17-2016
    Location
    chennai,india
    MS-Off Ver
    2013
    Posts
    11

    Re: To copy data from sheet-1 to sheet-2

    Thanks a lot it worked...also is there any basics or tutorials available to learn vba macros.Please help

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: To copy data from sheet-1 to sheet-2

    You're welcome. Glad I can offer some help
    There is a sticky thread at the forum that has a lot of links to useful tutorials and also use Google to search

+ 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. Replies: 1
    Last Post: 02-09-2017, 05:30 AM
  2. Replies: 9
    Last Post: 06-27-2016, 01:02 AM
  3. Replies: 2
    Last Post: 01-23-2016, 01:16 PM
  4. [SOLVED] Copy and paste data from sheet 2 to sheet 1 based on specific criteria on sheet 1
    By VBADUD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2012, 04:18 AM
  5. Copy Sheet / Create & Name New Sheet / Insert Before a Sheet / Paste Data
    By thinkspac in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2012, 02:27 PM
  6. [SOLVED] Macro to Copy Data from one Sheet A to Sheet B based on value in cell on sheet A
    By scass in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-11-2012, 07:21 PM
  7. Copy data from one sheet (Fixed Cells and sheet) to another sheet
    By RCatman23 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-21-2009, 12:56 PM

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