Thoughts on how to proceed or accomplish a batch report being created

Oberon70

Board Regular
Joined
Jan 21, 2022
Messages
160
Office Version
  1. 365
Platform
  1. Windows
Hi,

I want to thank everyone who has helped me in past. I have only been ready and learning about VBA for about a month now and usually, it is after work and when my family goes to sleep. It am enjoying it as a hobby and automating some of the tasks I am responsible for at work.

The big goal for me is taking the statement information I copy with VBA to a table and being able to create a batch report that then can be uploaded into a program I use at work, after that, well I have a few type of reports and tracking that I will eventually setup.

The code I have written does the following when I receive a statement, which can have up to 2000 transactions on it.

1. I run the VBA Code which lets me select the statement I want to load. The code checks to make sure the statement is not already on the Invoice Table. If it isn't, it then copies the details of the invoice to the Invoice Table.
2. The statement has a sheet called Data, which has the details of the invoice and all the transactions. I convert the range of transactions into a table and then copy the information I want to another workbook, which has two sheets; Invoice Database (which is a table to store the invoice details) and Transaction Database (which has a table to store all the transactions). This code works great. It is the next step I am not 100% sure how to proceed or what the best way is to proceed. The next step will only be dealing with the transaction table, however, the invoice table is how I am going to keep track that certain tasks have been done. i.e. the statement has been receipted, an email has been sent to the banking team to reconcile the deposit, a batch report has been created.

The batch report is what I would like to complete as it would assist my team in not being behind some of the actions and will free me up to handle other responsibilities. The batch report will upload to the program I use and update hundreds of files in a matter of minutes.

I know I can likely use code I wrote and was helped with that consolidated the transactions for manual receipting, but the code was written before I started learning about tables, which was a recommendation that was made to me.

The below is a mockup of a transaction spreadsheet, with just two short invoices.

Claim NumberRecovery AgentAgent's RefPortfolio CodeThird-PartyInvoice NumberInvoice DateAmountEx CommissionGSTInc CommissionNet AmountFile Reference 2
4625WCEWayne Enterprise55122WEAICustomer 1TX72821-31-202250.006.250.636.8843.12
6754WCEWayne Enterprise89994WEAICustomer 2TX72821-31-2022100.0012.501.2513.7586.25
6524WCEWayne Enterprise85378WEAICustomer 3TX72821-31-202220.002.500.252.7517.25
4625WCEWayne Enterprise55122WEAICustomer 1TX72821-31-202220.002.500.252.7517.25
6548WCEWayne Enterprise54782WEAICustomer 5TX72821-31-202250.006.250.636.8843.12
4625WCEWayne Enterprise55122WEAICustomer 1TX72821-31-202250.006.250.636.8843.12
6808WCEWayne Enterprise54866WEAICustomer 7TX72821-31-202250.006.250.636.8843.12
6050WCEWayne Enterprise82822WEAICustomer 8TX72821-31-202220.002.500.252.7517.25
5208WCEWayne Enterprise54771WEAICustomer 9TX72821-31-202220.002.500.252.7517.25
6808WCEWayne Enterprise54866WEAICustomer 7TX72821-31-202250.006.250.636.8843.12
6808WCEWayne Enterprise54866WEAICustomer 7TX72821-31-2022100.0012.501.2513.7586.25
6053WCEWayne Enterprise55063WEAICustomer 12TX72821-31-202220.002.500.252.7517.25
4834WCEWayne Enterprise54541WEAICustomer 13TX72821-31-202220.002.500.252.7517.25
5568WCEWayne Enterprise59998WEAICustomer 14TX72821-31-2022100.0012.501.2513.7586.25
6900WCEWayne Enterprise85377WEAICustomer 4TX72821-31-202250.006.250.636.8843.12
5729WCEWayne Enterprise85378WEAICustomer 16TX72821-31-202220.002.500.252.7517.25
6900WCEWayne Enterprise85377WEAICustomer 4TX72821-31-202230.003.750.384.1325.87
5774WCEWayne Enterprise85701WEAICustomer 18TX72821-31-202250.006.250.636.8843.12
6900WCEWayne Enterprise85377WEAICustomer 4TX72821-31-202210.001.250.131.388.62
6999WCEWayne Enterprise84664WEAICustomer 20TX72821-31-202225.003.130.313.4421.56
5951WCEWayne Enterprise84664WEAICustomer 21TX72821-31-202225.003.130.313.4421.56
6900WCEWayne Enterprise85377WEAICustomer 4TX72821-31-202220.002.500.252.7517.25
4625WCEWayne Enterprise55122WEAICustomer 1TX36623-17-20221969.00492.2549.23541.481427.53
6754WCEWayne Enterprise89994WEAICustomer 2TX36623-17-20221964.00491.0049.10540.101423.90
6524WCEWayne Enterprise85378WEAICustomer 3TX36623-17-20221199.00299.7529.98329.73869.28
4625WCEWayne Enterprise55122WEAICustomer 1TX36623-17-20221102.00275.5027.55303.05798.95
6548WCEWayne Enterprise54782WEAICustomer 5TX36623-17-202243.0010.751.0811.8331.18
4626WCEWayne Enterprise55122WEAICustomer50TX36623-17-20221550.00387.5038.75426.251123.75
6808WCEWayne Enterprise54866WEAICustomer 7TX36623-17-20221504.00376.0037.60413.601090.40
6050WCEWayne Enterprise82822WEAICustomer 8TX36623-17-2022709.00177.2517.73194.98514.03
5208WCEWayne Enterprise54771WEAICustomer 9TX36623-17-20221723.00430.7543.08473.831249.18
6808WCEWayne Enterprise54866WEAICustomer 7TX36623-17-20221996.00499.0049.90548.901447.10
6808WCEWayne Enterprise54866WEAICustomer 7TX36623-17-20221297.00324.2532.43356.68940.33
6053WCEWayne Enterprise55063WEAICustomer 12TX36623-17-20221455.00363.7536.38400.131054.88
4834WCEWayne Enterprise54541WEAICustomer 13TX36623-17-20221508.00377.0037.70414.701093.30
5568WCEWayne Enterprise59998WEAICustomer 14TX36623-17-2022492.00123.0012.30135.30356.70
6900WCEWayne Enterprise85377WEAICustomer 4TX36623-17-20221805.00451.2545.13496.381308.63
5729WCEWayne Enterprise85378WEAICustomer 16TX36623-17-20221535.00383.7538.38422.131112.88
6900WCEWayne Enterprise85377WEAICustomer 4TX36623-17-2022671.00167.7516.78184.53486.48
5774WCEWayne Enterprise85701WEAICustomer 18TX36623-17-20221074.00268.5026.85295.35778.65
6900WCEWayne Enterprise85377WEAICustomer 4TX36623-17-20221294.00323.5032.35355.85938.15
6999WCEWayne Enterprise84664WEAICustomer 20TX36623-17-2022706.00176.5017.65194.15511.85
5951WCEWayne Enterprise84664WEAICustomer 21TX36623-17-2022516.00129.0012.90141.90374.10
6900WCEWayne Enterprise85377WEAICustomer 4TX36623-17-2022379.0094.759.48104.23274.78


The claim number is a unique ID but can appear a few times in one statement as it depends on how often the customer pays in that invoice period. It can also only appear once.

Below is an example using the claim number 4625WCE

Claim NumberRecovery AgentAgent's RefPortfolio CodeThird-PartyInvoice NumberInvoice DateAmountEx CommissionGSTInc CommissionNet AmountFile Reference 2
4625WCEWayne Enterprise55122WEAICustomer 1TX72821-31-202250.006.250.636.8843.12
4625WCEWayne Enterprise55122WEAICustomer 1TX72821-31-202220.002.500.252.7517.25
4625WCEWayne Enterprise55122WEAICustomer 1TX72821-31-202250.006.250.636.8843.12
4625WCEWayne Enterprise55122WEAICustomer 1TX36623-17-20221969.00492.2549.23541.481427.53
4625WCEWayne Enterprise55122WEAICustomer 1TX36623-17-20221102.00275.5027.55303.05798.95


So, what I want to do is consolidate the transactions per invoice, I should then only see 4625WCE twice in a temporary table.

I have looked at pivot tables, but I don't fully understand them and I am not sure it will do what I want, which is to create a temporary table to be set up automatically when I click a button to create the report.

Claim NumberRecovery AgentAgent's RefPortfolio CodeThird-PartyInvoice NumberInvoice DateAmountEx CommissionGSTInc CommissionNet AmountFile Reference 2
4625WCE55122Customer 1TX72821-31-2022120.0015.001.5116.51103.49
4625WCE55122Customer 1TX36623-17-20223071.00767.7576.78844.532226.48


I do have an array code that was written for me that I use when sorting a statement for receipting. The array code will consolidate the transactions.

VBA Code:
Sub NMCopyTransactions()



'Dim DatabaseBook As Workbook, DataSh As Worksheet, ws As Worksheet

Dim LO_src As ListObject, DBR As Range 'everything of your 1st listobject

Dim LOH_dest_LC As ListColumn, iCol As Long 'evrything of your 2nd listobject

Dim MyColumn As Variant, bFlag As Boolean, cDest As Range, MyOtherColumn As String



'your workbook and worksheet

'Set DatabaseBook = Workbooks.Open(Filename:="G:\\Invoice_Database_Sheet.xlsx") 'the data is in this workbook

'Set DataSh = DatabaseBook.Sheets("Transactions_Database") 'and within this sheet





'your source

Set LO_src = Closedws.ListObjects("Transactions_Table") 'your "source" listobject

'Set LO_dest = Lo_Dest_Trans.ListObjects("TransactionsDatabase") 'your "destination" listobject



For Each MyColumn In Array("FILCLIREF1", "FILCLIREF1STRDESC", "STRPAYTAMT")



'what column in the 2nd listobject corresponds with a name in the 1st listobject

Select Case MyColumn 'if you get an error here, change MyColumn into cStr(myColumn)

Case "FILCLIREF1": MyOtherColumn = "Claim Number"

Case "FILCLIREF1STRDESC": MyOtherColumn = "Third-Party"

Case "STRPAYTAMT": MyOtherColumn = "Amount"

End Select



Set DBR = LO_src.ListColumns(MyColumn).DataBodyRange 'source = the databodyrange of that listcolumn, also here change in case of ... MyColumn into cStr(MyColumn)



'your destination

Set LO_dest_LC = loTranTable.ListColumns(MyOtherColumn) 'this listcolumn in that listobject

iCol = LO_dest_LC.Range.Column - loTranTable.Range.Column ' this is OFFSET for the x-th column of that table



'your copy

If Not bFlag Then 'the 1st loop, you assign cDest as the range if the column was the 1st column of your table

Set cDest = loTranTable.ListRows.Add.Range.Cells(1, 1).Resize(DBR.Rows.Count) '

bFlag = True 'set flag for the next loops

End If



cDest.Offset(, iCol).Value = DBR.Value 'OFFSET to the 1st listcolumn of that table

Next



End Sub

Is there a better way to consolidate the table? If not, then how would I modify it so it only consolidates the transactions by an invoice number and then claims number?

Then is there a way that I can then take the above temp table to create my batch report, which is only the following, but combines info from the table? The batch report will combine each claim number into one row.

Below is an example of what I am aiming for.

Claim NumberDiary NoteGross AmountInc Commission
4625WCEPayment(s) have been received on Invoice(s) TX7282 and TX3662 for the amount of $3,191.00. There is a commission charge of $2329.973191.00861.035


If a claim is number with transactions is on 10 invoices then totals will be summed together and all the invoices numbers would be listed in the dairy note.

Alternatively, I will have an entry for each invoice number and claim number, which is fine as I am hoping to stay within a 30 day period and shouldn't see a claim number appear on multiple statements.

Claim NumberDiary NoteGross AmountInc Commission
4625WCEPayment has been received on Invoice TX7282 for the amount of $120.00. There is a commission charge of $16.51.120.0016.51
4625WCEPayment has been received on Invoice TX3662 for the amount of $3071. There is a commission charge of $844.523191.00844.52


Anyway, I am sorry this ended up being so long:(, but appreciate any help or pointers to help me go into the right direction.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top