Results 1 to 4 of 4

Thread: Receipt Format

  1. #1

    Receipt Format

    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
    Attached Files Attached Files

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,478
    Location
    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
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    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
    Attached Files Attached Files

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,478
    Location
    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.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •