PDA

View Full Version : Receipt Format



mdasifiqbal
05-10-2017, 09:13 AM
Dear Friends

I have a receipt format for which I tried to record a macro for copy and paste of data to mater files named ''Bank_Log'' & ''Cash_Log'' from the Sheet ''Receipt'', Merged cell B9 has a dropdown with 5 options for first 4 option I want the data to be pasted from ''Receipt'' sheet to Sheet ''Bank_Log'' and when I choose the option "Cash'' the data should be pasted from ''Receipt'' Sheet to ''Cash_Log''. The data from Range B,C&D, F,G&H and J,K&L (13:22) should be stacked serially, there are chances that next receipt may contain fewer invoice count. Need your help to resolve the issue. highlighted cells in yellow are mandatory which needs to be copied and pasted in master sheets.

Thanks & Regards

Md Asif Iqbal

mdmackillop
05-10-2017, 10:58 AM
Here's a start. The other sheet is just a variation of the second case.

Option Explicit
Option Base 1
Sub Test()
Dim arr()
Dim i, j, k
Dim rng, tgt
With Sheets("Receipt")
Select Case .[B9]
Case "Cash"
' do other
Case Else
ReDim arr(30, 10)
arr(1, 1) = .[L3]
arr(1, 2) = .[L5]
'etc.
arr(1, 8) = .[D9]
'etc.
For i = 2 To 10 Step 4
For j = 13 To 22
k = k + 1
arr(k, 5) = .Cells(j, i)
arr(k, 6) = .Cells(j, i + 1)
arr(k, 7) = .Cells(j, i + 2)
Next j
Next i
Set tgt = Sheets("Bank_Log").Cells(Rows.Count, 6).End(xlUp).Offset(, -4)
For i = 1 To 30
For j = 1 To 10
tgt.Offset(i, j - 1) = arr(i, j)
Next j
Next i
End Select
End With
End Sub

mdasifiqbal
05-11-2017, 05:33 AM
Dear Freiends

I have made certain changes to the code, only thing left is when I choose Cash as option for payment the data is not copied from "Receipt" to "Cash-Log".

Thanks & Regards

Md Asif Iqbal

mdmackillop
05-11-2017, 09:28 AM
You've filled in the blanks. You need to replace "do other" with similar code to fill the array to suit the cash_log table layout.