SlideShare a Scribd company logo
1 of 7
Download to read offline
As accountant, FP&A or any other data custodian knows well, it is quite
uninteresting and down-right tiring doing the same mundane manual tasks
month-over-month year-after-year. We know there are better ways, but
not all of us have the technical knowledge to promote automation.
This is the main goal for the series of knowledge exchange articles I have
created and coined – “Well You Ought To Know”.
Basic automation has served me well throughout my career and I felt it
well about time for me to give back.
The articles will take the following form:
 Defining the scenario
 Walking through the solutions
 Benefit realized
Automating ADI journal entries:
extracting data from a text file to
Excel with VBA
Franklin Brown, CPA, CISSP, CRCP, CGEIT, CRISC  http://basoapbox.com/  9/2/2010
 Month End Close Automation
 Page 2
Defining The Scenario
Every month, as part of the month end
close process, the three text files with
data representing cash and marketable
securities movements are provided to
me by State Street.
My job is to remove the files from an ftp
server, open each file, copy the content
of each and paste the data to an ADI
journal template (Excel Add-in used to
upload journals to Oracle)
Then recalculate the data within Excel
to validate that my calculated totals
match each files trailer totals, assuring
no fat-thumb error. Then post the
journal.
 Month End Close Automation
 Page 3
The result of the automated (VBA macro) produces an ADI journal entry resembling the below image.
The macro open each file provided by State Street, parses each file line by line the creating a consolidated
ADI journal entry.
Consider that we started here (the below image), then in second after initiating the macro we have a journal
like the above image with over 100 or so line of transactions each month. The macro can handle as much
lines as your version of Excel allows.
And the content of the text files looks like:
 Month End Close Automation
 Page 5
Walking Through The Solution
Here we get to the sauce of this tutorial and the main ingredients are macros. What’s a macro you ask? In a quick
breath, macros are small programs written with Microsoft Visual Basic for Applications, VBA for short. Macros
are used for good and bad, I suggest you do a quick Google search to get more information amount macros.
For now, I will focus on breaking down the codes used for this automation. The hope is that you will be able to
copy and edit the code to fit your specific situation. This is not intended to be a beginners tutorial on macros.
There is a wealth of such tutorials online. Again, the main goal for these tutorials is for you to develop the
understanding that automation is your friend and for you to become system-minded.
This macro could have been written many ways and with different program languages. What I created was actually
copied from many sources online. I could have written for scratch and used a myriad of different methods – but
why waste the precious time.
I didn’t bother with references and acknowledgements to the gracious online contributors of the codes used.
Quite frankly there is nothing unique here.
Some key understandings to keep in mind:
 Comments within a macro proceed a single quote as in – ‘this is an example of a comment format
 Macro commands are executed within a single Sub procedure or using multiple sub
procedure(s)/function(s) using calls as in
Sub hello() ‘singular procedure macro
Msgbox(“hello world”) ‘a macro displaying message box with the text hello world in on sub
End Sub
-----------------------------------------------------------------------------------------------------------------------------------
Sub hello() ‘multiple procedure macro
Call msgboxHello ‘a macro displaying message box with the text hello world using two subs
End Sub
Sub msgboxhello()
Msgbox(“hello world”)
End Sub
-------------------------------------------------------------------------------------------------------------------------------------
 Month End Close Automation
Essentially there are three sub procedures at play for this macro. Sub LoopThroughFolder() is the starting point
for this macro. It call (jumps to) getHowManyRows() and getData(myFile As String) to do some of the work.
The getHowManyRows() sub procedure is used to clear rows 22 to the row in column B that has the text
Totals:. This assures that the template is clear every time before populating the data from the text file.
Sub LoopThroughFolder()
Dim myFile As String
Dim MyObj As Object
Dim MySource As Object
Dim myPath As String
Dim file As Variant
myPath = "C:UsersfbrownDesktopss" ‘creates a variable that reference a folder
file = Dir(myPath) ‘Dir function creates an array(a list) of all files in directory referenced
Application.EnableEvents = False ‘turn off any additional alerts within the workbook
Sheets("JE").Select ‘select (activate) worksheet named JE in the active workbook
Call getHowManyRows ‘jumps to getHowManyRows() sub procedure
Range("c21").Select ‘move the cursor to cell B20 of the active worksheet
While (file <> "") ‘function to iterate through all files in folder "C:UsersfbrownDesktopss"
myFile = "C:UsersfbrownDesktopss" & CStr(file)
Call getData(myFile) ‘jumps to getData(myFile) sub procedure
file = Dir ‘takes the next file referenced in the Dir object listing (array)
Wend
Application.EnableEvents = True ‘turn event alerts back on within the workbook
‘Next three codes enter formulas and text into respective cells. ActiveCell.Row is the current row
Range("M" & ActiveCell.Row + 1).Formula = "=SUM(M20:M" & ActiveCell.Row - 1 & ")"
Range("M" & ActiveCell.Row + 1).Formula = "=SUM(M20:M" & ActiveCell.Row - 1 & ")"
Range("I11").value = "SSB-KC GL FEED PAM "
End Sub
Sub getHowManyRows()
Dim tRows As Long
Range("b20").Select ‘moves the cursor to cell B20 of the active worksheet
Selection.End(xlDown).Select ‘use to the first non-empty row in current column B
to find the last row in column B
tRows = ActiveCell.Row ‘give variable tRows the row value of the current cell
(eg. If current cell is A31 tRows will equal 31)
‘used to remove all rows form 22 to tRows ( rows 22 to 31 removed using above example)
If ActiveCell.Row > 22 Then
Rows("22:" & tRows - 1).Select
Selection.Delete Shift:=xlUp
End If
End Sub
 Month End Close Automation
 Page 7
The getData(myFile As String) sub procedure processes all the lines of the current file. Depending of each line
content, further data transformation and extraction methods and conditionals are performed.
Benefit realized includes:
 Reduced journal processing time
 Reduced journal errors due to fat-thumb errors
Sub getData(myFile As String)
Dim text As String, textline As String, posLat As Integer, posLong As Integer
Dim header As String
Open myFile For Input As #1 ‘open file into memory for reading as a file object reference by#1
Do Until EOF(1) ‘ keep doing until last line - end of file (EOF): used to loop through each record of file
Line Input #1, textline ‘read the current line records into textline String variable
‘if textline String contains PAM enter If block from second character
If Mid(textline, 2, 3) = "PAM" Then
header = Mid(textline, 30, 19)
‘header now equals the textline’s characters 30 to 49 - example textline = “JPAM hello the
world keeps turning even if we want to get off” header = “ning even if we wan” 30 to 49
characters of textline bolded to illustrate the Mid function
End If
If Len(textline) = 106 Then ‘confirms that textline relates to an actual entry as is not a header
‘following 11 lines use the Mid function power to extract string required for each cell
Range("c" & ActiveCell.Row) = Mid(textline, 2, 3)
Range("d" & ActiveCell.Row) = Mid(textline, 5, 4)
Range("e" & ActiveCell.Row) = Mid(textline, 9, 1)
Range("f" & ActiveCell.Row) = Mid(textline, 10, 7)
Range("g" & ActiveCell.Row) = Mid(textline, 17, 4)
Range("h" & ActiveCell.Row) = Mid(textline, 21, 6)
Range("i" & ActiveCell.Row) = Mid(textline, 27, 3)
Range("j" & ActiveCell.Row) = Mid(textline, 30, 3)
Range("k" & ActiveCell.Row) = Mid(textline, 33, 2)
Range("l" & ActiveCell.Row) = "0000"
Range("o" & ActiveCell.Row) = Mid(textline, 57, 20)
‘nested If statement used to confirm a debit or credit entry if value contains a – then it is a
credit enter in column N else it is a Debit enter in column M
If Mid(textline, 48, 1) = "-" Then
Range("n" & ActiveCell.Row) = CDbl(Mid(textline, 35, 13))
Else
Range("m" & ActiveCell.Row) = Mid(textline, 35, 13)
End If
ActiveCell.Offset(1, 0).Select ‘select one row down
ActiveCell.EntireRow.Insert ‘inserts a new row
End If
Loop
Close #1
End Sub

More Related Content

Similar to Well You Ought To Know (WYOTK) FP&A Automation Series

Web-IT Support and Consulting - bulk dBase (DBF) exports via Microsoft Excel ...
Web-IT Support and Consulting - bulk dBase (DBF) exports via Microsoft Excel ...Web-IT Support and Consulting - bulk dBase (DBF) exports via Microsoft Excel ...
Web-IT Support and Consulting - bulk dBase (DBF) exports via Microsoft Excel ...Dirk Cludts
 
Article link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxArticle link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxfredharris32
 
Mastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_argumentsMastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_argumentsRuth Marvin
 
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Bill Buchan
 
Nt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language AnalysisNt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language AnalysisNicole Gomez
 
Code That Writes Code : Automatic Programming for NHibernate
Code That Writes Code : Automatic Programming for NHibernateCode That Writes Code : Automatic Programming for NHibernate
Code That Writes Code : Automatic Programming for NHibernateDeepak Sahu
 
MDE=Model Driven Everything (Spanish Eclipse Day 2009)
MDE=Model Driven Everything (Spanish Eclipse Day 2009)MDE=Model Driven Everything (Spanish Eclipse Day 2009)
MDE=Model Driven Everything (Spanish Eclipse Day 2009)Jordi Cabot
 
Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)pbarasia
 
Python Modules, Packages and Libraries
Python Modules, Packages and LibrariesPython Modules, Packages and Libraries
Python Modules, Packages and LibrariesVenugopalavarma Raja
 
BAS 150 Lesson 8 Lecture
BAS 150 Lesson 8 LectureBAS 150 Lesson 8 Lecture
BAS 150 Lesson 8 LectureWake Tech BAS
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabvikrammutneja1
 
Visual basic 6.0
Visual basic 6.0Visual basic 6.0
Visual basic 6.0Aarti P
 
Chapter 16-spreadsheet1 questions and answer
Chapter 16-spreadsheet1  questions and answerChapter 16-spreadsheet1  questions and answer
Chapter 16-spreadsheet1 questions and answerRaajTech
 
Task Perform addition subtraction division and multiplic.pdf
Task Perform addition subtraction division and multiplic.pdfTask Perform addition subtraction division and multiplic.pdf
Task Perform addition subtraction division and multiplic.pdfacsmadurai
 

Similar to Well You Ought To Know (WYOTK) FP&A Automation Series (20)

Web-IT Support and Consulting - bulk dBase (DBF) exports via Microsoft Excel ...
Web-IT Support and Consulting - bulk dBase (DBF) exports via Microsoft Excel ...Web-IT Support and Consulting - bulk dBase (DBF) exports via Microsoft Excel ...
Web-IT Support and Consulting - bulk dBase (DBF) exports via Microsoft Excel ...
 
Article link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxArticle link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docx
 
Mastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_argumentsMastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_arguments
 
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
 
Vb.net ii
Vb.net iiVb.net ii
Vb.net ii
 
Nt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language AnalysisNt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language Analysis
 
Code That Writes Code : Automatic Programming for NHibernate
Code That Writes Code : Automatic Programming for NHibernateCode That Writes Code : Automatic Programming for NHibernate
Code That Writes Code : Automatic Programming for NHibernate
 
Ad507
Ad507Ad507
Ad507
 
Vb.net iv
Vb.net ivVb.net iv
Vb.net iv
 
MDE=Model Driven Everything (Spanish Eclipse Day 2009)
MDE=Model Driven Everything (Spanish Eclipse Day 2009)MDE=Model Driven Everything (Spanish Eclipse Day 2009)
MDE=Model Driven Everything (Spanish Eclipse Day 2009)
 
Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)
 
Python Modules, Packages and Libraries
Python Modules, Packages and LibrariesPython Modules, Packages and Libraries
Python Modules, Packages and Libraries
 
MS Access Macros
MS Access MacrosMS Access Macros
MS Access Macros
 
Tech talk
Tech talkTech talk
Tech talk
 
BAS 150 Lesson 8 Lecture
BAS 150 Lesson 8 LectureBAS 150 Lesson 8 Lecture
BAS 150 Lesson 8 Lecture
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Visual basic 6.0
Visual basic 6.0Visual basic 6.0
Visual basic 6.0
 
Chapter 16-spreadsheet1 questions and answer
Chapter 16-spreadsheet1  questions and answerChapter 16-spreadsheet1  questions and answer
Chapter 16-spreadsheet1 questions and answer
 
ArduinoWorkshop2.pdf
ArduinoWorkshop2.pdfArduinoWorkshop2.pdf
ArduinoWorkshop2.pdf
 
Task Perform addition subtraction division and multiplic.pdf
Task Perform addition subtraction division and multiplic.pdfTask Perform addition subtraction division and multiplic.pdf
Task Perform addition subtraction division and multiplic.pdf
 

Recently uploaded

RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一F La
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...Suhani Kapoor
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一fhwihughh
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAmazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAbdelrhman abooda
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)jennyeacort
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样vhwb25kk
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]📊 Markus Baersch
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdfHuman37
 

Recently uploaded (20)

꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAmazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf
 

Well You Ought To Know (WYOTK) FP&A Automation Series

  • 1. As accountant, FP&A or any other data custodian knows well, it is quite uninteresting and down-right tiring doing the same mundane manual tasks month-over-month year-after-year. We know there are better ways, but not all of us have the technical knowledge to promote automation. This is the main goal for the series of knowledge exchange articles I have created and coined – “Well You Ought To Know”. Basic automation has served me well throughout my career and I felt it well about time for me to give back. The articles will take the following form:  Defining the scenario  Walking through the solutions  Benefit realized Automating ADI journal entries: extracting data from a text file to Excel with VBA Franklin Brown, CPA, CISSP, CRCP, CGEIT, CRISC  http://basoapbox.com/  9/2/2010
  • 2.  Month End Close Automation  Page 2 Defining The Scenario Every month, as part of the month end close process, the three text files with data representing cash and marketable securities movements are provided to me by State Street. My job is to remove the files from an ftp server, open each file, copy the content of each and paste the data to an ADI journal template (Excel Add-in used to upload journals to Oracle) Then recalculate the data within Excel to validate that my calculated totals match each files trailer totals, assuring no fat-thumb error. Then post the journal.
  • 3.  Month End Close Automation  Page 3 The result of the automated (VBA macro) produces an ADI journal entry resembling the below image. The macro open each file provided by State Street, parses each file line by line the creating a consolidated ADI journal entry. Consider that we started here (the below image), then in second after initiating the macro we have a journal like the above image with over 100 or so line of transactions each month. The macro can handle as much lines as your version of Excel allows.
  • 4. And the content of the text files looks like:
  • 5.  Month End Close Automation  Page 5 Walking Through The Solution Here we get to the sauce of this tutorial and the main ingredients are macros. What’s a macro you ask? In a quick breath, macros are small programs written with Microsoft Visual Basic for Applications, VBA for short. Macros are used for good and bad, I suggest you do a quick Google search to get more information amount macros. For now, I will focus on breaking down the codes used for this automation. The hope is that you will be able to copy and edit the code to fit your specific situation. This is not intended to be a beginners tutorial on macros. There is a wealth of such tutorials online. Again, the main goal for these tutorials is for you to develop the understanding that automation is your friend and for you to become system-minded. This macro could have been written many ways and with different program languages. What I created was actually copied from many sources online. I could have written for scratch and used a myriad of different methods – but why waste the precious time. I didn’t bother with references and acknowledgements to the gracious online contributors of the codes used. Quite frankly there is nothing unique here. Some key understandings to keep in mind:  Comments within a macro proceed a single quote as in – ‘this is an example of a comment format  Macro commands are executed within a single Sub procedure or using multiple sub procedure(s)/function(s) using calls as in Sub hello() ‘singular procedure macro Msgbox(“hello world”) ‘a macro displaying message box with the text hello world in on sub End Sub ----------------------------------------------------------------------------------------------------------------------------------- Sub hello() ‘multiple procedure macro Call msgboxHello ‘a macro displaying message box with the text hello world using two subs End Sub Sub msgboxhello() Msgbox(“hello world”) End Sub -------------------------------------------------------------------------------------------------------------------------------------
  • 6.  Month End Close Automation Essentially there are three sub procedures at play for this macro. Sub LoopThroughFolder() is the starting point for this macro. It call (jumps to) getHowManyRows() and getData(myFile As String) to do some of the work. The getHowManyRows() sub procedure is used to clear rows 22 to the row in column B that has the text Totals:. This assures that the template is clear every time before populating the data from the text file. Sub LoopThroughFolder() Dim myFile As String Dim MyObj As Object Dim MySource As Object Dim myPath As String Dim file As Variant myPath = "C:UsersfbrownDesktopss" ‘creates a variable that reference a folder file = Dir(myPath) ‘Dir function creates an array(a list) of all files in directory referenced Application.EnableEvents = False ‘turn off any additional alerts within the workbook Sheets("JE").Select ‘select (activate) worksheet named JE in the active workbook Call getHowManyRows ‘jumps to getHowManyRows() sub procedure Range("c21").Select ‘move the cursor to cell B20 of the active worksheet While (file <> "") ‘function to iterate through all files in folder "C:UsersfbrownDesktopss" myFile = "C:UsersfbrownDesktopss" & CStr(file) Call getData(myFile) ‘jumps to getData(myFile) sub procedure file = Dir ‘takes the next file referenced in the Dir object listing (array) Wend Application.EnableEvents = True ‘turn event alerts back on within the workbook ‘Next three codes enter formulas and text into respective cells. ActiveCell.Row is the current row Range("M" & ActiveCell.Row + 1).Formula = "=SUM(M20:M" & ActiveCell.Row - 1 & ")" Range("M" & ActiveCell.Row + 1).Formula = "=SUM(M20:M" & ActiveCell.Row - 1 & ")" Range("I11").value = "SSB-KC GL FEED PAM " End Sub Sub getHowManyRows() Dim tRows As Long Range("b20").Select ‘moves the cursor to cell B20 of the active worksheet Selection.End(xlDown).Select ‘use to the first non-empty row in current column B to find the last row in column B tRows = ActiveCell.Row ‘give variable tRows the row value of the current cell (eg. If current cell is A31 tRows will equal 31) ‘used to remove all rows form 22 to tRows ( rows 22 to 31 removed using above example) If ActiveCell.Row > 22 Then Rows("22:" & tRows - 1).Select Selection.Delete Shift:=xlUp End If End Sub
  • 7.  Month End Close Automation  Page 7 The getData(myFile As String) sub procedure processes all the lines of the current file. Depending of each line content, further data transformation and extraction methods and conditionals are performed. Benefit realized includes:  Reduced journal processing time  Reduced journal errors due to fat-thumb errors Sub getData(myFile As String) Dim text As String, textline As String, posLat As Integer, posLong As Integer Dim header As String Open myFile For Input As #1 ‘open file into memory for reading as a file object reference by#1 Do Until EOF(1) ‘ keep doing until last line - end of file (EOF): used to loop through each record of file Line Input #1, textline ‘read the current line records into textline String variable ‘if textline String contains PAM enter If block from second character If Mid(textline, 2, 3) = "PAM" Then header = Mid(textline, 30, 19) ‘header now equals the textline’s characters 30 to 49 - example textline = “JPAM hello the world keeps turning even if we want to get off” header = “ning even if we wan” 30 to 49 characters of textline bolded to illustrate the Mid function End If If Len(textline) = 106 Then ‘confirms that textline relates to an actual entry as is not a header ‘following 11 lines use the Mid function power to extract string required for each cell Range("c" & ActiveCell.Row) = Mid(textline, 2, 3) Range("d" & ActiveCell.Row) = Mid(textline, 5, 4) Range("e" & ActiveCell.Row) = Mid(textline, 9, 1) Range("f" & ActiveCell.Row) = Mid(textline, 10, 7) Range("g" & ActiveCell.Row) = Mid(textline, 17, 4) Range("h" & ActiveCell.Row) = Mid(textline, 21, 6) Range("i" & ActiveCell.Row) = Mid(textline, 27, 3) Range("j" & ActiveCell.Row) = Mid(textline, 30, 3) Range("k" & ActiveCell.Row) = Mid(textline, 33, 2) Range("l" & ActiveCell.Row) = "0000" Range("o" & ActiveCell.Row) = Mid(textline, 57, 20) ‘nested If statement used to confirm a debit or credit entry if value contains a – then it is a credit enter in column N else it is a Debit enter in column M If Mid(textline, 48, 1) = "-" Then Range("n" & ActiveCell.Row) = CDbl(Mid(textline, 35, 13)) Else Range("m" & ActiveCell.Row) = Mid(textline, 35, 13) End If ActiveCell.Offset(1, 0).Select ‘select one row down ActiveCell.EntireRow.Insert ‘inserts a new row End If Loop Close #1 End Sub