Sie sind auf Seite 1von 11

Path to highlight developer Tab:

2007—Office Button---Excel Option---Popular—Show


Developer Tab
2010/13—File—Options—Customize Ribbon---Developer

Procedure: Strt & End of a Macro


Two type of Procedure
1. Sub Procedure
2. Function Procedure
Syntax of Sub Procedure:

Sub Macroname()
Commands
End Sub

Syntax for Function Procedure:


Function FunctionName(arg)
Calculation
End Function
Object Model:
1.Object:ExcelApp,Workbook,Sheets,Cells,Charts,Images,
Shapes…….
2.Property:Feature of an object
3.Method:Action Performed On an Object
Object Browser—F2

Coding Procedure:
Object.property/Method

Variable Declaration: Allocation Memory to your


program
Syntax:
Dim Variable as Datatype
Datatype:
1.Type of data
2.Memory
3.Holding Capacity
Byte: Num(+) 1B 0 to 255
Integer: Num(+/-) 2B -32768 to +32767
Long: Num(+/-) 4B -2L to +2L
Single: NUm(+/-/dec) 4B
Double: NUm(+/-/dec) 8B
String: All type of data(text format) 16B
Variant: All type of data(own format) 16-32B

Byte=200
X as byte
X=200

Dim X as Byte
X=200

Ways of declaration
Dim x as byte
Dim y as byte
Dim x as byte, y as string

Dim x , y as byte

Dim x , y
Loops: Repeatition/Iteration
1.For Next Loop: It can used when we are aware of how
many times to run the Loop.
2.Do Loop:It can used when we are not aware of how
many times to run the Loop
1.Do While:Runs the loop if condition given is true
2.Do until:Runs the Loop if condition given is False
3.For each Next Loop:it can be used only when group of
objects are available
For Next Loop Syntax:
Forward Loop:
For Variable=Minval to Maxval step +
Commands
Next Variable

Reverse Loop:
For Variable=Maxval to Minval step –
Commands
Next Variable

Decision Making Statement:


1.IF Stmt
2.Case Stmt
Different ways of IF stmt:
1. IF condition then result

2. IF Condition then
Result
Else
Result
End if

3. Nested IF:
IF Condition then
Result
Elseif condtion then
Result
Else
Result
End if
Case Stmt:
And--to or—“,”
Select Case Value
Case1
Result
Case2
Result
Case else
Result
End select
2.Do Loop:It can used when we are not aware of how
many times to run the Loop
1.Do While:Runs the loop if condition given is true
2.Do until:Runs the Loop if condition given is False

Do While Condtion(T)
Commands
Loop

Do Until Condition(F)
Commands
Loop
3.For each Next Loop:it can be used only when group of
objects are available
For each Variable in Group of objects
Commands
Next variable
VBA/Worksheetfunctions:
VBA Functions All Platform whr VBA Supported
Worksheetfunction Can be used only on spreadsheet

VBA Functions Date & time/Text Functions


Worksheetfunction Arithmetic Function/Lookup & reference Function

Excel Functions VBA Function


Lower Lcase
Upper Ucase
Value Val
InstrRev
Find(FT,WT,[Sn]) Instr([SN],WT,FT)
Isnumber Isnumeric
Char Chr
Code Asc
Text Format
Today date
Ctrl+shft+; time
Date Dateserial
Datedif Datediff

Das könnte Ihnen auch gefallen