In how many ways we can create Macros?

     

     

     

     

    In how many ways can perform record macro

     

    Option#1

     

    Click on Developer Tab

    Click on "Record Macro" under CODE group

     

     

    Option#2

     

     

    Option#3

     

    Click on VIEW Tab

    Under the "Macros" group click on RECORD MACRO

     

     

    Absolute Reference & Relative Reference

     

     

     

  • By default excel records macros in ABSOLUTE REFERENCE
  •  

  • Absolute refers to EXACT location of cells, when recroding macros
  •  

  • While recording the macro if we entered the value in E5, while executing(using every time) the macro we need to place the value in E5 cell only., else marcro doesn't word
  •  

  • If we entered INCOME in E5 cell while recording marcro, while executing macro every time we need to enter INCOME in E5 cell only
  •  

    Relative Reference

     

  • Excel provides the relation to starting cell, while recroding macro
  •  

  • While using the relative reference we can enter the INCOME in any cell
  •  

    Relative Reference Activation

     

     

 

 

 

Absolute Vs Relative Reference

 

  • Color Headers
  • In case of Absolute reference: only header will color
  • Whereas in relative reference: Where ever we need we can color
  •  

    Sub absolute_reference()
    ' ' absolute_reference Macro
    ' ' Range("B4").Select
    With Selection.Interior
    .Pattern = xlSolid
    .PatternColorIndex = xlAutomatic
    .Color = 65535
    .TintAndShade = 0
    .PatternTintAndShade = 0
    End With
    Range("B5").Select
    With Selection.Interior
    .Pattern = xlSolid
    .PatternColorIndex = xlAutomatic
    .ThemeColor = xlThemeColorAccent2
    .TintAndShade = -0.499984740745262
    .PatternTintAndShade = 0
    End With
    End Sub
    Sub Relative_Refernce()
    ' ' Relative_Refernce Macro
    ' ' With Selection.Interior
    .Pattern = xlSolid
    .PatternColorIndex = xlAutomatic
    .Color = 192
    .TintAndShade = 0
    .PatternTintAndShade = 0
    End With
    ActiveCell.Offset(1, 0).Range("A1").Select
    With Selection.Interior
    .Pattern = xlSolid
    .PatternColorIndex = xlAutomatic
    .ThemeColor = xlThemeColorAccent3
    .TintAndShade = -0.249977111117893
    .PatternTintAndShade = 0
    End With
    End Sub

     

     

    Autofilter - Add & Remove

     

  • Record Macro - Autofilter
  •  

    Sub Add_Autofilter()
    ' ' Add_Autofilter Macro
    ' ' Range("A1:F1").Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$F$130").AutoFilter Field:=2, Criteria1:="Banana"
    End Sub
    Sub removeautofilter()
    ' ' removeautofilter Macro
    ' ' Range("A1").Select
    ActiveCell.FormulaR1C1 = "Item"
    Range("A1").Select
    Selection.AutoFilter
    End Sub

     

     

     

    Record Macro - Color a Table

     

     

    Record Macro - Live Code Generation

     

     

     

    Record Macro - Countif Function