Page 1 of 1

copy data

Posted: Mon Sep 12, 2022 3:35 pm
by sna
Hi there!
I'd like to say hi ,code was used to get the data starting from rows 2 to end. The cash used to display in the Particulars column and was filled with as many rows with value in column A. I am trying to edit the code and get the values from rows 7 in this workbook along with the date but I think I have not edited it properly. I need your expertise to help me to correct the code and to get the Cash in the right column as well fill the column Line with nos starting from 1 to end like in the expected sheet with the help of the code.

Thank you in advance.

Re: copy data

Posted: Mon Sep 12, 2022 7:35 pm
by snasui
:D Try this,

Code: Select all

Dim arr As Variant, arrb(9999, 3) As Variant
Dim i As Integer, j As Integer, k As Integer
With Worksheets("Extract")
    arr = .Range("a6").CurrentRegion.Offset(1, 0)
    For j = 1 To UBound(arr, 2)
        For i = 1 To UBound(arr, 1)
            If Not IsEmpty(arr(i, j)) Then
                arrb(k, 0) = .Cells(1, j).Value
                arrb(k, 1) = "Cash"
                arrb(k, 2) = arr(i, j)
                arrb(k, 3) = k + 1
                k = k + 1
            End If
        Next i
    Next j
End With
With Worksheets("Daily").Range("a1")
    If k > 0 Then
        .CurrentRegion.ClearContents
        .Resize(1, 4).Value = Array("Date", "Particulars", "Amount", "Line")
        .Offset(1, 0).Resize(k, 4).Value = arrb
    End If
End With

Re: copy data

Posted: Mon Sep 12, 2022 8:31 pm
by sna
Thank you 😊