?
Solved

Excel - Auto-Create Journal Entries

Posted on 2016-08-24
1
Medium Priority
?
123 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 33

Accepted Solution

by:
Subodh Tiwari (Neeraj) earned 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

840 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