LEARN from the Collection of MS EXCEL VBA Macros Codes/Examples

Visual Basic for Automation (Macros Collection)

  1. Calculate Business Working Days (Excluding Saturdays and Sundays)

  1. Resize Form during Run-Time

  1. Export Excel Charts to PowerPoint Presentation

  1. Partly Background Color a Cell (Coloring only a portion of Cell)
  2. Show Gridlines on Colored Range

Event Macro
  1. Example of Worksheet_Change Event Macro
  2. Color Entire Row based on a column's value

  1. Access Internet Explorer (Search Engine Example)
  2. Change Image Location
  3. Export Excel Worksheets to MS Word
  4. Export Excel Charts to PowerPoint Presentation
  5. Replace Characters of filenames in a directory
  6. Shrink or Reduce Excel Workbook/File Size
  7. Notifying with Flash Window
  8. Speed up Excel Start Up
  9. How to schedule a VBA Macro? 
  10. Excel 2003 style menu in Excel 2007 / 2010
  11. Optimize VBA Code for FASTER Macros (Recommended)

  1. Change a Number Polarity/Sign
  2. Convert Numbers to Text
  3. Convert Textual Numbers to Values 
  4. Convert Formulas to Values

  1. Color a range based on its percentage value

  1. Delete Blank Rows
  2. Remove Empty Columns
  3. Select Alternate Rows
  4. Select Alternate Columns
  5. Square shaped Rows and Columns. i.e. squared cells

  1. Invert the Selection
  2. Select Alternate Rows
  3. Select Alternate Columns 

  1. Change Case (Upper, Lower, Proper, Sentence and Toggle)
  2. Remove Extra Spaces (Left, Right, Both sides and from Inside)
  3. SuperScript/Subscript First or Last Character 
  4. Apply RainBow color to the Text 
  5. Extract Alphabets from a Text (Removing all Digits Occurrences)
  6. Extract Digits from a Text (Removing all Alphabets Occurrences)
  7. Reverse the Text in Selected Cells (Mirroring the Entire Cell Contents) 
  8. Delete 'n' number of characters from selected range.


  1. Force save and unsave of a workbook
  2. Close all saved workbooks

  1. Sort all sheets on the basis of their names
  2. Remove blank worksheets from Current workbook
  3. Color all Sheet Tabs
  4. Remove color from all sheet tabs
  5. Protect all worksheets
  6. Unprotect all worksheets in a workbook
  7. Remove Password (Unprotect) all worksheets
  8. Insert 'n' number of Blank Worksheets 
  9. Show Grid on Colored Range
  10. Create Graph Cells/ Convert to Squared Cell Range

User Defined Functions
  1. Nth Vlookup and Nth Hlookup Formulas
  2. Validate E-mail addresses
  3. Extract Alphabets from alpha-numeric combination range
  4. Extract Digits from alpha-numeric combination range
  5. Count 5 Consecutive Zeros
  6. Calculate Business Working Days between 2 dates