Hi,
I am giving some basic information about Macro. Hope it would be helpful:
A macro is a piece of programming code that runs in Excel environment and helps automate routine tasks.
Macros are one of the developer features. By default, the tab for developers is not displayed in excel.
1. First turn on the Developer Tab
The difference between a function and a sub in Excel VBA is that a function can return a value while a sub cannot. Functions and subs become very useful as program size increases.
I am giving some basic information about Macro. Hope it would be helpful:
A macro is a piece of programming code that runs in Excel environment and helps automate routine tasks.
Macros are one of the developer features. By default, the tab for developers is not displayed in excel.
- If you want to save macros, then you must save your workbook in a macro-enabled format *.xlsm
- The macro name should not contain any spaces.
- Always fill in the description of the macro when creating one. This will help you and others to understand what the macro is doing.
- Code placed on a sheet (assigned to a command button) is only available for that particular sheet.
1. First turn on the Developer Tab
- Right click anywhere on the ribbon, and then click Customize the Ribbon.
- Under Customize the Ribbon, on the right side of the dialog box, select Main tabs (if necessary).
- Check the Developer check box.
- Click OK.
- You can find the Developer tab next to the View tab.
- On the Developer tab, click Insert.
- In the ActiveX Controls group, click Command Button.
- Drag a command button on your worksheet.
- Right click CommandButton1 (make sure Design Mode is selected).
- Click View Code.
- Place your cursor between Private Sub CommandButton1_Click() and End Sub.
- Add the code line shown below.
- Close the Visual Basic Editor
- Click the command button on the sheet (make sure Design Mode is deselected).
- Dim temp As Double
- temp = Range("A1").Value
- Range("A1").Value = Range("B1").Value
- Range("B1").Value = temp
The difference between a function and a sub in Excel VBA is that a function can return a value while a sub cannot. Functions and subs become very useful as program size increases.
No comments:
Post a Comment