Showing posts with label Excel. Show all posts
Showing posts with label Excel. Show all posts

How to write macro in Excel

Please  follow below steps to write Macro.

Step 1: Create a new Excel Application
Step 2: Press Alt + F11,it will open code behind window.


Step 3: By right clicking -ThisWorkbook- select Insert -> Module


Step 4: Write Hello world Program.

Sub Helloworld()
MsgBox "Hello World!!!"
End Sub

Step 5: Press F5.Msgbox will shown as   "Hello World!!!"




How to access worksheet in excel using VBA

By declaring variable as Worksheet, we can access worksheet and cell in excel.
Dim sht1 As Worksheet
Set sht1 = Worksheets(1)
sht1.Cells(1,1) = "Hello World"