Solved

Excel - Auto-Create Journal Entries

Posted on 2016-08-24
1
66 Views
Last Modified: 2016-08-28
Hi,

I have an external table that I would like to download to excel each month and then create journal entries.  The rows on the external file vary per month.  I would like to set this up so I'm not having to copy/paste or creating new formulas each month.  Below is an example of the external table and what I would like the end result to look like.  .  Please let me know if this is possible.

'Before'
Batch      Amount      Date
11568      100         6/30/2016
11475      50          6/30/2016
11837      300              6/30/2016

'After'
Batch      Amount      Date      Type
11568      100      6/30/2016      Debit
11475      50      6/30/2016      Debit
11837      300      6/30/2016      Debit
11568      100      6/30/2016      Credit
11475      50      6/30/2016      Credit
11837      300      6/30/2016      Credit
0
Comment
Question by:Wonderwall99
1 Comment
 
LVL 30

Accepted Solution

by:
Subodh Tiwari (Neeraj) earned 500 total points
ID: 41769295
Please try this....

In the attached, click the button on Sheet1 to create Journal.
Sub CreateJournal()
Dim sws As Worksheet, dws As Worksheet
Dim slr As Long, rng As Range
Application.ScreenUpdating = False
Set sws = Sheets("Sheet1")
slr = sws.Cells(Rows.Count, 1).End(xlUp).Row
Set rng = sws.Range("A2:C" & slr)
On Error Resume Next
Set dws = Sheets("Journal")
dws.Cells.Clear
On Error GoTo 0
If dws Is Nothing Then
   Sheets.Add(before:=Sheets(1)).Name = "Journal"
   Set dws = ActiveSheet
End If
dws.Range("A1:D1").Value = Array("Batch", "Amount", "Date", "Type")
rng.Copy dws.Range("A2")
dws.Range("D2:D" & slr).Value = "Debit"
rng.Copy
dws.Range("A" & Rows.Count).End(3)(2).PasteSpecial xlPasteAll
dws.Range("D2:D" & (slr * 2) - 1).SpecialCells(xlCellTypeBlanks).Value = "Credit"
dws.Columns.AutoFit
dws.Range("A1").CurrentRegion.Borders.Color = vbBlack
dws.Activate
dws.Range("A1").Select
Application.ScreenUpdating = True
End Sub

Open in new window

CreateJournal.xlsm
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question