120+ Professional Project Management Templates!

Save Up to 85% LIMITED TIME OFFER

Excel VBA Examples

Learn Excel VBA by Examples, it is easy to follow the codes and learn Excel VBA from our examples codes.

Find Last Column with data in Worksheet using Excel VBA

2022-06-17T03:53:15+00:00

Example to show you how to find last used column with data in a Excel worksheet using VBA . It helps if you want to loop through all columns of a worksheet. We need to find last Column with data in a Worksheet Sheet if we want to loop through all columns of the worksheet using Excel VBA. For examples, my data changes every time but I need to perform same task for each column. In this situation I need to know the last column of the data every time the perform the task.

Find Last Column with data in Worksheet using Excel VBA2022-06-17T03:53:15+00:00

Save Workbook Using Excel VBA to Specific Folder

2022-06-17T03:52:54+00:00

Solutions: You can use SaveAs method to Save the File Example: Sub ExampleToSaveWorkbook() Workbooks.Add 'Saving the Workbook ActiveWorkbook.SaveAs "C:WorkbookName.xls" 'OR 'ActiveWorkbook.SaveAs Filename:="C:WorkbookName1.xls" End Sub

Save Workbook Using Excel VBA to Specific Folder2022-06-17T03:52:54+00:00

Open and Close Excel Workbook using VBA

2022-06-17T03:52:53+00:00

Solution: You can use the Open method to Open an Existing Workbook Example: The following code create a new workbook and save in the C drive Sub ExampleOpenAnExistingWorkbook() Workbooks.Open "C:WorkbookName.xls" 'OR 'Workbooks.Open Filename:="C:WorkbookName1.xls" End Sub

Open and Close Excel Workbook using VBA2022-06-17T03:52:53+00:00

Create New Workbook in Excel VBA

2022-06-17T03:52:52+00:00

Solution: You can use Add method to create new workbook Example: The following code create a new workbook and save in the C drive Sub ExampleAddNewWorkbook() 'Adding New Workbook Workbooks.Add 'Saving the Workbook ActiveWorkbook.SaveAs "C:WorkbookName.xls" 'OR 'ActiveWorkbook.SaveAs Filename:="C:WorkbookName1.xls" End Sub

Create New Workbook in Excel VBA2022-06-17T03:52:52+00:00

Get Active Workbook or Worksheet Name Path FullName in Excel VBA

2022-06-17T03:52:44+00:00

When we are working with workbooks and worksheets, some times we may required to access the workbook name or a worksheet name.

Solution:
You can get a workbook or a worksheet names by using Name property of the workbook or worksheet.
Get Active Workbook or Worksheet Name Path FullName in Excel VBA2022-06-17T03:52:44+00:00

Run a Macro Automatically on Opening Excel Workbook

2022-06-17T03:52:36+00:00

Sometimes you may want to run a particular macro automatically while opening the excel file.

Example Cases:
  • You may want to show a welcome message to the user
  • You may want to run some sarting scripts before while opening the workbook
  • You may want to fill some data while opening the workbook
  • You may want to activate a particular sheet while opening the workbook
  • You may want to show a user form while opening the workbook
Solution:
We can use Workbook_Open() method or Auto_Open() method to achieve this.
Run a Macro Automatically on Opening Excel Workbook2022-06-17T03:52:36+00:00
Go to Top