http://www.analystsdigest.com
Summary of my previous blogs is stated below.
Data Analysis means analyzing the sorted and organized data statistically and logically. The means are various coding languages if data is quite big. For example, VBA Macros in MS – Office. VBA means visual basic for applications. Official name is “Visual Basic, Applications Edition. VBA is the most vast language amongst high level languages.
How to Write Excel Macros in VBA?
1.) Open Microsoft Excel.
2.) Press Alt+F11(VBA IDE will get opened). OR Go to Tools -> Macros -> VBA Editor.
3.)Insert Module. Write VBA code in that Module.
4.) Remember each module must start with subroutine and end with subroutine.
For example -
Sub Macro1()
“Code in between these two extreme lines”
End Sub
Below are the images for Excel file first then VBA Editor after pressing Alt+F11.
Alt+F11
You can directly run macros from the VBA Editor by clicking the play sign on the tool bar Or you can assign the macro to an event say to a button. The event will then be button click. See below.
You can also record a macro if you have a repetitive task to perform on the daily basis. Follow the steps stated below.1.) Go to View -> Record macro
2.) A window will appear which will ask you to select your macro’s name, click OK to keep it default which is of the form macro1 or macro2 etc, else change it and then click OK.
3.) After clicking OK in the above dialog box your recording will start. Then you just need to perform your daily basis tasks on the excel sheet. After finishing the tasks
Go to View -> Stop Recording.
The recording helps in the repetitive tasks that are required to be performed on the daily basis. Recording also helps coders in several other ways. For example if we have a task that requires some repetitive work and some non repetitive work, then we can record the repetitive part and code the remaining part.
Basically there are Four ways of writing macros.
1.) Record complete macro as elaborated previously in the blog. This can only handle repetitive tasks.
2.) Record macros in parts. For example if your task comprises of both repetitive and non repetitive parts.
3.) Record Complete Macro and then tweak. For example if the whole task is repetitive but attributes or variables might change.
4.) Write Complete Code. Helps in better understanding of the task and is completely error free and code maintains itself as it is dynamic.
Mostly the third way of coding is used in most organizations where the complete code is recorded and is then tweaked as per user’s need. This saves time because we do not have to apply logic for each and every minute detail. Code is then tweaked in between. Tweaking involves putting loops, conditions etc.
Today we learned ‘How to record a macro?’ My next blog will be focused on the VBA coding manually.
AnalystsDigest