Excel VBA - Lesson 1 - Basics

1,847 views
1,626 views

Published on

Published in: Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,847
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Excel VBA - Lesson 1 - Basics

  1. 1. Lesson 1
  2. 2. 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.
  3. 3. 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.
  4. 4. 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)
  5. 5. 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
  6. 6. 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
  7. 7. 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
  8. 8. In the next Lesson –1. Reading and Understanding Recorded Code2. Macros and Security3. Classes , Modules and Procedures

×