We all imagine that doing Programming inExcel, is to add new things to Excel and so itis some thing not easy to learn.Interestingly programming Excel is not reallyabout adding new features as much as it isabout combining existing features to solvespecific problems.
Programming in Excel is to make some task easierand more reliable.Through Programming, you are asking Excel to docertain tasks and Excel Follows that.Programming languages make things easierbecause they are great at performing repetitiveoperations and following a logical path withoutgetting tired or bored. They make things morereliable because they follow your directions andnever, ever get creative.
The best way to learn Macros and break theice is by recording code.Thru this you can learn about Excel objects,properties, and methods. We will discuss thesame in detail, in coming slides. When we record a macro, we can see that, itis rather writing a code on its own ( a visualbasic code)
Let us record a macro with a regular activity Which we repeatedly use on our daily routine. For Example, with a particular Data, I wanted to change the format and convert that into a Graph. Choose Tools - > Macros -> Record New Macro A dialog box appears as shown here ( Record Macro)Select Data Format Option Select Format
Select Data Insert Charts Simple Graph Appears While Recording Macro, “Record Macro” Button, becomes a small Blue Square. Once your Recording is over, you need to stop recording as shown below
The task described in earlier slide ,was recorded in thebelow Macro Sub Macro1() macro_1 Macro Range("A2:B6").Select ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$2:$B$6"), , xlYes).Name = _ "Table2" Range("Table2[#All]").Select ActiveSheet.ListObjects("Table2").TableStyle = "TableStyleMedium2" ActiveSheet.Shapes.AddChart.Select ActiveChart.SetSourceData Source:=Range("Sheet1!$A$2:$B$6") ActiveChart.ChartType = xlColumnClustered End Sub
In the next Lesson –1. Reading and Understanding Recorded Code2. Macros and Security3. Classes , Modules and Procedures