+ Reply to Thread
Results 1 to 7 of 7

Macro copying rows to coulm based on specific criteria

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    239

    Macro copying rows to coulm based on specific criteria

    Hi all
    I sincerely thank all the members of forum.
    I am really in a need of a help for copying row to colum based on Acoulm I have done example for the first few
    This arrangement is required for writing letters through mail merge.
    Your immediate help is sincerely solicited
    Illustration is attached

    Thanks & Regards
    N.Srinivasan
    Attached Files Attached Files

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Macro copying rows to coulm based on specific criteria

    Hi N.Srinivasan,
    try it
    Sub ertert()
    Dim x, i&, j&, k&, s$
    x = Range("A1:C" & Cells(Rows.Count, 1).End(xlUp).Row).Value
    ReDim y(1 To UBound(x), 1 To 5)
    
    For i = 2 To UBound(x)
        If x(i, 1) = s Then
            j = j + 2: If j > UBound(y, 2) Then ReDim Preserve y(1 To UBound(y), 1 To j)
            y(k, j - 1) = x(i, 2)
            y(k, j) = x(i, 3)
        Else
            k = k + 1: j = 3
            y(k, 1) = x(i, 1)
            y(k, 2) = x(i, 2)
            y(k, 3) = x(i, 3)
            s = x(i, 1)
        End If
    Next i
    
    Range("D2").Resize(k, UBound(y, 2)).Value = y()
    End Sub

  3. #3
    Forum Contributor
    Join Date
    09-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    239

    Re: Macro copying rows to coulm based on specific criteria

    Thanks a lot
    It works great
    many thanks for reliving from me doing from monotonour work

  4. #4
    Forum Contributor
    Join Date
    09-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    239

    Re: Macro copying rows to coulm based on specific criteria

    Hi
    Can you Please help
    I need to copy row to coulm Exaample file is attached.
    Previoous verison had 3 colums to be distributed now One more colum is added pls help
    Attached Files Attached Files

  5. #5
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Macro copying rows to coulm based on specific criteria

    try this
    Sub ertert()
    Dim x, i&, j&, k&, s$
    x = Range("A1:D" & Cells(Rows.Count, 1).End(xlUp).Row).Value
    ReDim y(1 To UBound(x), 1 To 5)
    
    For i = 2 To UBound(x)
        If x(i, 1) = s Then
            j = j + 2: If j > UBound(y, 2) Then ReDim Preserve y(1 To UBound(y), 1 To j)
            y(k, j - 1) = x(i, 3) 'DATE
            y(k, j) = x(i, 4) 'AMOUNT
        Else
            k = k + 1: j = 4
            y(k, 1) = x(i, 1)
            y(k, 2) = x(i, 2)
            y(k, 3) = x(i, 3)
            y(k, 4) = x(i, 4)
            s = x(i, 1)
        End If
    Next i
    
    Range("F2").Resize(k, UBound(y, 2)).Value = y()
    End Sub

  6. #6
    Forum Contributor
    Join Date
    09-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    239

    Re: Macro copying rows to coulm based on specific criteria

    Hi
    Hi
    I need one more help.
    Row colum is to be arranged based on the colum A and B to gether
    Presently it is following colum a
    If there are more than on flat in tower 4 it combines in the same row.
    can you please extend this coding.
    thanks

  7. #7
    Forum Contributor
    Join Date
    09-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    239

    Re: Macro copying rows to coulm based on specific criteria

    Hi Nilem,
    I have missed to thank you very much your coding on 25/04/2016. It works fine and superb.

    Now can you please help me to give coding for the above post.
    Presently it looks colum A for every change in colum A it arranges row to colum wise
    We have above 10 towers and each tower shall have same flat no.101 102 etc.
    Coding shall look for change in colum A and Colum ie tower no flat no and then arranges to row colum
    can you pls help.
    Thanks

+ 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: 7
    Last Post: 09-30-2014, 01:44 PM
  2. [Solved] Copying Cells from one sheet to another based on specific criteria
    By james.heston in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-30-2013, 09:51 AM
  3. Replies: 6
    Last Post: 06-27-2012, 04:38 PM
  4. Copying rows from 1 worksheet to another with specific criteria and no duplicates
    By jennys83 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-28-2012, 09:30 AM
  5. Macro to move rows, row by row, based upon specific criteria.
    By luke8182 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-20-2012, 01:05 PM
  6. How can I delete rows based on specific criteria using a macro?
    By akouleze in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-24-2011, 02:49 AM
  7. Copying rows from another sheet based on specific criteria
    By jamesbrown008 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-06-2011, 01:53 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