Learning Visual Basic For Excel To Do Programming.

Asked By 30 points N/A Posted on -
qa-featured

Visual Basic is an integrated development environment from Microsoft. This language is easy to learn and simple. How can learning visual basic for Excel be done?

SHARE
Answered By 0 points N/A #92933

Learning Visual Basic For Excel To Do Programming.

qa-featured

First step is to get started with VBA Excel provides many formulas to do many tasks but it cannot sort data or move it with formulas. It is better to do programming to carry out such tasks. For this VBA i.e. Visual Basic for applications can be used. 

  • Open Excel sheet.
  • VBA is disabled in all the spreadsheets by default. Previously it was knows as macros.
  • First you have to enable VBA. Go to the file menu and select the Customize option.
  • Check the developer box which will allow the Developer icon to appear.
  • Next you have to allow the Excel to execute the programs.
  • Go to the File menu and select trust center.
  • Click on Macro settings and enable all the macros.

STEPS:

  • Programs are written in workbook page called module.
  • Open VBA editor.
  • Type the command Insert Macro Module to insert a new module.
  • New module looks like a blank-sheet.
  • You can type in the module and edit it as well. Backspace has the same default meaning.
  • You can save the module.
  • In the program the beginning is sub name(). Name is the program name and sub stands for sub-routine.
  • Ending is end sub. Both of them are VBA keywords.
  • The body of the program includes the following lines:


  •  
  • MsgBox “MESSAGE” The text in double quotes is displayed as it is in the execution.
  • After writing the program click on the green arrow in the toolbar.
  • You can press F5 button thrice. A dialog box will appear.
  • Click on the run button.

A simple example:

Sub percent()

MsgBox ”the program gives students percentage”

SUB1=InputBox (“enter marks of subject 1”)

SUB2=InputBox (“enter marks of subject 2”)

Percentage=Application.Pmt(SUB1,SUB2)

End Sub

  • This is a basic example for VBA program

Login/Register to Answer

Related Questions