2 May 2012

How to create Macro in Excel | Simple example for macro in excel | how to display alert in Excel


                      Hi Friends, in this article i will explain about How to create Macro in Excel 2007.
                   A macro is a set of operations for a spreadsheet. Suppose if you want to open new excel file, the file name is in A1 ,for that we can write the code in Macro and Run the macro then the file will open.


How to create a Macro:

1.Click on the Developer tab, if it is not in the menu then follow the below steps.
      1.Click on Microsoft office button (top left) and then click on the Excel Options.


      2.In the Popular category, in Top options for working with Excelselect Show                            Developer tab in the Ribbon checkbox and then click OK.



2.  click on  Developer tab and then click on View Code then the Microsoft Visual Basic code will open.Write the code for the Spreadsheet and Goto Excel and click on the Macros and Run.



Example:

The below example is display the alert in Excel
Copy and paste the below code in the Microsoft Visual Basic code  and Goto Excel and click on the Macros and Run.


Sub Roja()
           Sheets("Sheet1").Select
           Range("A1").Value = “Roja”
           MsgBox "You entered the name Roja" 

      End Sub

  
The output of the above code will like below figure.



No comments:

Post a Comment