• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro to copy and paste data into categories, taking reference from a certain column

jchia

New Member
Hi,

I would need some help in copy and pasting data into categories using a macro. In my file, there are name, rate and date columns. The date column vary across various months and dates. In the pasted data, for example if the date indicates 5-Dec-24, I would need the data to be categorised under 'Dec-24' & 2-Jan-25 needs to be classified under header 'Jan-25' etc.. Cells B4:D10 consists of the raw data and cells J3:L13 consists of the desired data I would need after using the macro. Could I please get some help and expertise from the community? thank you!
 

Attachments

  • Jo.xlsx
    9.4 KB · Views: 3
Hi, according to your attachment a starter VBA demonstration :​
Code:
Sub Demo1()
        Const F = "mmm-yy"
        Dim R&, S$
   With [B3].CurrentRegion.Rows
       .Sort .Cells(3), 1, Header:=1
        R = Application.CountA(.Columns(3))
        If R < .Count Then .Item(R + 1 & ":" & .Count).Clear
    For R = R To 2 Step -1
        S = Format$(.Cells(R, 3), F)
        While Format$(.Cells(R - 1, 3), F) = S:  R = R - 1:  Wend
       .Item(R).Insert
       .Cells(R, 1) = S
    Next
   End With
End Sub
Do you like it ? So thanks to click on bottom right Like !​
 
Back
Top