The Complete MBA Coursework Series
Automate The Boring Tasks Using VBA
Introduction to Excel
Tips You Must Know About MS Word
MY LORD, INCREASE MY KNOWLEDGE Noble Quran
A Tale of Two Brothers
Hicham and Mohamed Ibnalkadi
Table of contents
Preface
Motivation
This book is designed as a part of The Complete MBA Coursework Series, established to equip the professionals and students with the eminent capabilities and hone their skillset. The motivation behind this series is the need to establish a thorough and complete MBA coursework, following the core and elective courses of prestigious institutions like Wharton and Harvards Business Schools. With this self-motivated study of the MBA curriculum, students and professionals can tailor their MBA according to their interests and need. Thus, embarking on this self-study MBA coursework rather than a traditional, costly, and lengthy MBA degree program is worth the time.
MBA degree programs are very costly, although the skill boost associated is worth acquiring. Thus, as a part of the MBA coursework series, the following book helps the students learn the basic terminologies and techniques associated with Visual Basic (VBA) . This book does not attempt to provide a self-contained discussion of VBA. Instead is a decent introductory to useful VBA macros that can automate Boring tasks in Excel . Further, the introductory is stemmed from our professional experience. Finally, we want to thank Hina Aslam and Sara Aslam for providing us with many suggestions and valuable feedback on this book.
Prerequisites
To make the book as accessible as possible, the reader should have the basic working knowledge of Visual Basic language.
Final few words
Thank you for buying this book, and feedback is highly appreciated for enhancing future versions. I hope that all readers gain something useful from this book and boost their knowledge of econometrics that the author aimed at while writing it.
Although this book has been thoroughly checked and proofread, typos, errors, inconsistencies in notation, and instances where I have got it wrong are bound to sneak in. Any readers spotting such errors or addressing certain questions or comments are kindly requested to contact our customer service through this email ( ) before writing any review online. Finally, feel free to return the book and ask for a refund if unsatisfied.
A Tale of Two Brothers
Hicham and Mohamed Ibnalkadi
Zoohra.com
Introduction
The purpose of this document is to describe the usage of 20 macros developed to help automate boring tasks in Microsoft Excel.
Visual Basic for Application, also known as VBA is an interface for the user to interact and program with an applications inner objects and programming structures. Many applications have a VBA interface, like AutoCad, CATIA and, of course, all Office Suite.
VBA can be used to program macros, automate tasks and customize interfaces and files. The language used for programming a VBA interface, is also known as VBA and consists of a version of the widely used Visual Basic language, also known as VB. However, it is important to notice that they are not the same languages, each of them has its own particularities, although they share the same syntax.
Most programs that have a VBA interface also have a way for the user to record its own macros. It is then easier to understand how to program certain actions, but in order to being able to write more complex and therefore useful programs, a certain level of programming knowledge is necessary.
To be able to access the VBA interface in Excel, first we need to make sure that the developer ribbon is displayed. To do so, goto File > Options > Customize the Ribbon and then check the Developer ribbon.
Now we can, for example, record one macro by clicking Developer > Record Macro and clicking Ok. Then we can perform any action inside Excel. When we are done, we can just go to Developer > Stop Recording . The resulting macro can be executed by pressing Alt + F8 or by going to Developer > Macros. If you click Run , the action you just recorded will be repeated, and if you click Edit , then you can view the resulting code of your macro.
In the following pages we will be describing the use of 20 example macros written to automate tasks in Excel. A step by step guide is provided to each of them, so that any user can understand how to operate them. The code for each macro is also provided, so that all the inner workings can be understood.
All the macros are contained in the file MacroUtilities_v01_00.xlsm inside the Main module. For convenience, they are placed in the same order as in this document.
Some of the macros also contain a user form, which is a Windows screen where the user can make selections and perform actions. All user forms for those macros are identified by the names in this text and they contain code, which is also provided in the text. Below is a table of each
# | Macro | Description |
| RemoveEmptyRows | Removes empty rows from active worksheet used range. (Example given) |
| RangeSwap | Swap the contents of two selected ranges of same size. |
| WorkbookIndex | Creates a workbook index sheet that can be used to navigate to other sheets within the workbook. |
| FillBlankCellsWithValue | Fills all blank cells in current selection with a specific value. |
| FormulasToValues | Changes all cells that contains formulas in active sheet into their respective values. |
| ExportAllVisibleSheetsPDF | Exports al visible worksheets as PDF |
| GroupAllShapes | Groups all shapes in active worksheet. |
| RemoveDuplicateRows | Removes duplicate rows from active worksheet used range. |
| CreateChainOfShapes | Creates rectangle shapes connected by arrows based on worksheet list. |
| SplitValue | Splits the value of a cell into a given number of cells so that the new cells have all the same value and add up to the original value. |
| ProtectAllFormulas | Protects all cells with formulas in active worksheet |
| HideUnhideWorksheets | Hides or unhides worksheets according to user selection. |
| PaintSelectionColor | Paints selected cell(s) in a specific color. |
| PaintColumnAndRow | Paints the whole row and column of a cell selected by the user in a given color. |
| FileteredCellsToNewWorksheet | Copies the filtered cells into a new worksheet. |
| SplitJoinTexts | Splits the contents of a cell into many cells or joins selected cells into one single cell given the user selection. |
| InsertSelectedRangeMultipleTimes | Inserts selected rows a given number of times under or above another given range. |
| GetFileOrFolderPath | Opens file or folder picker dialog so that the user can select a file or folder in the system. Once the selection is performed, the selected path is written to a given range. |