Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# Excel - Auto-Create Journal Entries

Posted on 2016-08-24
Medium Priority
117 Views
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
Question by:Wonderwall99
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
1 Comment

LVL 33

Accepted Solution

Subodh Tiwari (Neeraj) earned 2000 total points
ID: 41769295

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
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
``````
CreateJournal.xlsm
0

## Featured Post

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
###### Suggested Courses
Course of the Month9 days, 20 hours left to enroll