The Most Useful Excel VBA Codes and Example Macros designed to help you while writing VBA procedures to automate daily tasks. Learning will be easier if we have suitable examples. We have provided selected examples to deal with different objects, methods and properties in Excel. Numerous free useful VBA codes and tips will help you to deal with various Excel Objects like Cell, Range, Worksheets, Workbooks, Charts, Pivot Tables, and Hyperlinks. Also provided free example codes to deal with MS Word, PowerPoint, Outlook, Access, Other Applications and File Handling. If you think that I missed any useful code, please feel free to write us. We will respond with a solution with in couple of days and publish here to make it available for all VBA Users.
The Most Useful Excel VBA Codes and Example Macros! Learning Path
Learn VBA by examples and do almost everything! We have explained verity of examples to cover most frequently used codes. Start learning…
- Cells and Range Objects
- Rows and Columns Objects
- Worksheet and Workbook Objects
- Pivot Tables
- Other Applications
- Application Object
- Folders and File Handling
Cells and Range Objects :
Reading data from a Cell was my first exciting VBA Code when I stared learning Excel VBA. Then I successfully write data to Excel Cells. That was my first happy moment which motivated me to engage with VBA from last 10 years.
Here are the common examples to deal with Cell and Range Objects of Worksheet.
You can find examples on reading and writing the data, selecting, copying and pasting the data.
Clearing, changing font color, font to bold, background color of cells or range. We can also see the examples on merging cells, adding comments and changing the font case to lower or upper using Excel VBA.
- Write Data to Worksheet Cell in Excel VBA
- Writing and Reading Excel Worksheet Cells Ranges in VBA
- Read or Get Data from Worksheet Cell to VBA in Excel
- Select Cell Range in Excel VBA
- Copy Data from One Range to Another in Excel VBA
- Clear Cells in Excel Range Worksheet using VBA
- Change Font Color in Excel VBA
- Change Font to Bold in Excel VBA
- Change Text Case – Upper Lower in Excel VBA
- Change Background Color of Cell Range in Excel VBA
- Merge UnMerge Cell Range in Excel VBA
- Add Clear Comments in Excel VBA
Rows and Columns Objects:
Cell and Range objects helps to reading and writing the data from worksheet.
Now we will look into Rows and Columns of the Worksheet, helps to show or hide the data.
Here you can find the examples on changing row height, column width. Hiding or un-hiding columns or rows.
Inserting or deleting Rows or Columns. And finding the Last row, or columns in the worksheet in different situations.
- Change Row Height and Column Width using Excel VBA
- Delete Rows and Columns in Excel VBA
- Hide UnHide Columns in Excel Worksheet using VBA
- Hide UnHide Rows in Excel Worksheet using VBA
- Finding last used Column with data in particular Row
- Finding last used Row with data in particular Column
- Inserting Columns in Excel Worksheet using VBA
- Inserting Rows in Excel Worksheet using VBA
- Find Last Column with data in Worksheet using Excel VBA
- Finding last used Row with data in Excel Worksheet using VBA
Worksheet and Workbook Objects
Now we will see the examples on Worksheet and Workbook Objects. Here you can find creating new workbook, opening, closing and saving workbook. And example to show running a macro on opening or staring the workbook. We will also see how to protecting or unprotecting Excel workbooks or worksheets, Copying the data from one worksheet to another worksheet.
Hiding and unhiding worksheets. Changing the tab color of worksheet. Activating workbooks or worksheet, etc.
- Create New Workbook in Excel VBA
- Run a Macro Automatically on Opening Excel Workbook
- Open and Close Excel Workbook using VBA
- Save Workbook Using Excel VBA to Specific Folder
- Protect and Unprotect Excel Workbook using VBA
- Protect and UnProtect Worksheets in Excel VBA
- Hide UnHide Worksheets in Excel VBA
- Delete Worksheet in Excel VBA
- Copy Data from one Worksheet to another in Excel VBA
- Change the Color of Sheet Tabs in Excel VBA
- Activate Workbook Or Worksheet in Excel VBA
- Get Active Workbook or Worksheet Name Path FullName in Excel VBA
Hyperlinks are most widely used concepts in Excel. We generally use hyperlinks to navigate or open a file, link or folder. But we can do many other things using Hyperlinks. Examples in this topic will show you the power of Hyperlinks in Excel VBA.
Another powerful tool in Excel is charting. You can create rich visualized dashboards using Excel Charts and VBA. We have covered most commonly used Charting VBA examples.
Examples in this topic will show you how to deal with different chart objects to automate the charting process. Examples on creating charts, changing chart types. Changing chart axes titles, etc.
- Example tutorials on Creating Charts using Excel VBA:
- Example tutorials on Chart Type using Excel VBA:
- Example Tutorials on Formatting Chart Objects using Excel VBA:
- Example Tutorials on Chart Collection in Excel VBA:
- Other useful Examples and tutorials on Excel VBA Charting:
- Excel VBA Charting Constants and Enumeration
Tables in Excel help to manage our data in Excel and give the more control over the data. In this example we will see the different examples like creating tables, sorting table data and applying filters in the data.
- Create Tables in Excel VBA
- Sorting Tables in Excel VBA
- Filtering Tables in Excel VBA
- Clear Toggle Table Filters in Excel VBA
Pivot tables help us to summarize the data and analyze it. Example code provided for creating pivot tables, pivot charts, adding calculated fields in the pivot tables.
Names are another time saving feature in the Excel. We can define the names to Cells, Ranges and Tables and use them across the worksheets in the workbook. Her we will see how to add or remove the Names. Hiding and un-hiding names from the users.
VBA is powerful, it can interact with the other applications like MS Word, PowerPoint, Access, Outlook, Internet Explorer, VBScript etc. Here are examples to deal with other application from Excel.
Mastering the Application Objects Examples help you to fasten your VBA programs and writing optimized code in Excel VBA. Examples for stopping or displaying application alerts, stopping or enabling screen updating, stopping or enabling application events.
File handling examples are provided to creating deleting files, folder. Copying Files and Folders and Moving from one location to another location. And displaying file or folder dialog boxes to browse the files or folders.
- Check if Folder Exists using Excel VBA
- Opening Folders using VBA Excel
- Creating Folders in Excel VBA
- Copying Folders From One Location to Another in Excel VBA
- Move Folder From One Location to Another in Excel VBA
- Deleting Folders in VBA Excel
- Make File Read Only in VBA Excel
- Copy all Excel Files One Folder to Another in VBA Excel
- Opening Files Using File Dialog Box in Excel VBA
- Customize File or Folder Dialog Box in VBA Excel
- Excel VBA File Dialog Box – Displaying Vanilla Dialog Box to Pick Files
- Delete Files Using VBA
- Copy Files from One Location to Another folder or directory in Excel VBA