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 - dBase exports
Web-IT Support and Consulting - dBase exportsWeb-IT Support and Consulting - dBase exports
Web-IT Support and Consulting - dBase exportsDirk 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 - dBase exports
Web-IT Support and Consulting - dBase exportsWeb-IT Support and Consulting - dBase exports
Web-IT Support and Consulting - dBase exports
 
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

Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Delhi Call girls
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubaihf8803863
 
Aminabad Call Girl Agent 9548273370 , Call Girls Service Lucknow
Aminabad Call Girl Agent 9548273370 , Call Girls Service LucknowAminabad Call Girl Agent 9548273370 , Call Girls Service Lucknow
Aminabad Call Girl Agent 9548273370 , Call Girls Service Lucknowmakika9823
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
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
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiSuhani Kapoor
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改atducpo
 
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
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
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
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystSamantha Rae Coolbeth
 
Digi Khata Problem along complete plan.pptx
Digi Khata Problem along complete plan.pptxDigi Khata Problem along complete plan.pptx
Digi Khata Problem along complete plan.pptxTanveerAhmed817946
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
Predicting Employee Churn: A Data-Driven Approach Project Presentation
Predicting Employee Churn: A Data-Driven Approach Project PresentationPredicting Employee Churn: A Data-Driven Approach Project Presentation
Predicting Employee Churn: A Data-Driven Approach Project PresentationBoston Institute of Analytics
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 

Recently uploaded (20)

Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
 
Aminabad Call Girl Agent 9548273370 , Call Girls Service Lucknow
Aminabad Call Girl Agent 9548273370 , Call Girls Service LucknowAminabad Call Girl Agent 9548273370 , Call Girls Service Lucknow
Aminabad Call Girl Agent 9548273370 , Call Girls Service Lucknow
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
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
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
 
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
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
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
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data Analyst
 
Digi Khata Problem along complete plan.pptx
Digi Khata Problem along complete plan.pptxDigi Khata Problem along complete plan.pptx
Digi Khata Problem along complete plan.pptx
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
Predicting Employee Churn: A Data-Driven Approach Project Presentation
Predicting Employee Churn: A Data-Driven Approach Project PresentationPredicting Employee Churn: A Data-Driven Approach Project Presentation
Predicting Employee Churn: A Data-Driven Approach Project Presentation
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 

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