In this repo I will dicuss about-
- Basic of VBA as a programming language
- Recording some basic Macros
- VBA terminology
- Writting some Macros
- Debugging Macros
- Adding the Macros into Ribbon or interface
VBA stands for Visual Basic Applications. VBA is tool for programming, editing and running application code. Here apllication mean Excel. So thats means actually run code using Excel. VBA is not standalone program it work based on host application like Excel. It is Microsoft Event-driven program.
- custom design of our own functions
- Macros are very hard to undo
indicating C3 cell
- Range("C3")
- Range("b2").Range("b2")
- Cells(3,3)
- [C3]
- Range("A1").Offset(2,2)
` Selecting a Cell
Range("C3").Select
` Input a value in a Cell
Selection.Value = "Hello World"
` Change color to yellow to the cell
Selection.Interior.Color = vbYellow
` Clear the value to the cell
Range("C3").Clear
` Change current sheet name
ActiveSheet.Name = "Porfolio"
` Select a sheet named "sheet1"
sheets("sheet1").Select
Selection.CurrentRegion.Select
-
Changing font Styles using VBA (Font Styles.xlsx).
1.Sub TimeNewRoman() ` TimeNewRoman Macro ` Keyboard Shortcut: Ctrl+Shift+T Cells.Select Selection.Font.Name = "Times New Roman" End SubSub TimeNewRoman() ' ' TimeNewRoman Macro ' ' Keyboard Shortcut: Ctrl+Shift+T ' Cells.Select With Selection.Font .Name = "Times New Roman" End With End Sub- From macro recorder
Sub verdona() ' ' verdona Macro ' ' Keyboard Shortcut: Ctrl+Shift+S ' With Selection.Font .Name = "Verdana" .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic .TintAndShade = 0 .ThemeFont = xlThemeFontNone End With End Sub