Copy Data based on number of Trip

JERRY89
4StarLounger
Posts: 449
Joined: 21 Feb 2016, 02:52

Copy Data based on number of Trip

Post by JERRY89 »

Dear All,

I have an Excel where i need to manually to copy the Amount, KG and Description based on number of Trip to Column A to C , is there any method to simplify.
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 69449
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Copy Data based on number of Trip

Post by HansV »

How about this macro?

Code: Select all

Sub CopyData()
    Dim r As Long
    Dim m As Long
    Dim t As Long
    Dim n As Long
    Application.ScreenUpdating = False
    Range("A3:C" & Rows.Count).ClearContents
    m = Range("I" & Rows.Count).End(xlUp).Row
    t = 3
    For r = 3 To m
        n = Range("I" & r).Value
        Range("A" & t).Resize(n, 3).Value = Range("J" & r).Resize(1, 3).Value
        t = t + n
    Next r
    Application.ScreenUpdating = True
End Sub
Regards,
Hans

JERRY89
4StarLounger
Posts: 449
Joined: 21 Feb 2016, 02:52

Re: Copy Data based on number of Trip

Post by JERRY89 »

Hi Hans,

It is too perfect, thanks for your great solution. :cheers: :thankyou: