snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
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.
You do not have the required permissions to view the files attached to this post.
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