Record Macro Open xlmacros.

xls, sheet 1 Go to Tools on Menu bar and select Macros Record macro Fill in the required details in Macros dialog box. Select cells A1 to D10 Apply the following formats to selected cells Change font to Tahoma and font size to 12 Right align and bold Change font color to red and pattern to yellow Stop recording Macro View Macro Code in Visual Basic Editor Run Macro OOPs - Object Oriented Programming What are the objects in Excel?? Sheet Cells - Rows, columns, range Workbook Charts "Object.Method" or "Object.Property" Range Property Range("A1:D10").select Range("A1,D10").select Range("A1").select Cells Property Cells(row num, col num).selct Cells(2,1).select Cells(3,5).select Rows Property rows(rowindex).select rows(10).select Column Property columns("A:A").select Columns("A:B").select.....?! Worksheets Property worksheets("JunkFood").range("A1:B10").select sheet1.range("A1:B10").select Sheet2.cells(2,3).select Workbooks("trail_book1.xls").sheet1.cells(1,1).select Write a simple program to display sum of two cells in a message box.

3). 3).Value > 40 Then Sheet2.value = total End Sub Conditional Statements 1.Cells(i. total as integer a = cells(1.Interior.Activate Range("A1:D5").Activate dim i as integer For i = 2 To 20 If Sheet2.1).Value total = a + b 'Cells(3. 1).ColorIndex = 7 ElseIf Sheet2.Cells(i.Cells(i.ColorIndex = 5 End Sub Sub condition() 'code to check the value in a single cell and color code it Sheet2. b.Interior.Value b = Cells(2.Value > 30 Then Sheet2.value total = a + b Cells(3.Sub sum() Dim a.ColorIndex = 9 End If Next i End Sub Looping Statements: .1). 1). 4.Value = total MsgBox "The sum total is " & total End Sub Sub try() Sheet1.1).Activate a = Cells(1. 1). 2. 3). 3). 3.Interior. Simple IF IF and ELSE IF ELSEIF Nested IF Codes: Sub sum() 'code to add 2 nums from the sheet Dim a.value b = cells(2. b. total As Double Sheet2.Select Selection.Cells(i.

3).Cells(i...Value > 30 Then .. Next i "=> i=i+1" Do While Loop i = 1 ->Initial Do while <condition> i<=20 .Cells(i.Cells(i. ==> Only if condn fails.Cells(i. ==> Only if condn is satisfie d.Interior..ColorIndex = 12 End If i = i + 1 MsgBox i Loop End Sub Sub condition13() 'code to check the value in a single cell and color code it Dim i As Integer Sheet2. 3).Value > 40 Then Sheet2. .. i=i+1 -> increment Loop Do Until Loop Do. Next For i = 1 to 10 .Interior.ColorIndex = 9 ElseIf Sheet2..Activate i = 2 Do While Sheet2.Value = "" . contr ol enters the loop If Sheet2.. 3).Value > 40 Then Sheet2. 3).Cells(i.Cells(i.. ..Interior.Cells(i.....ColorIndex = 7 ElseIf Sheet2. control enters the loop If Sheet2...Value <> "" . Loop While Do.. .Cells(i.Cells(i. 3)....Cells(i.Initialization Condition Increment For Loop -> For.. 3). 3)...Activate i = 2 Do Until Sheet2.Value > 20 Then Sheet2. 3).Interior. Loop Until Sub condition12() 'code to check the value in a single cell and color code it Dim i As Integer Sheet2. . 3).Value > 30 Then Sheet2... 3).. 3).Cells(i. .ColorIndex = 7 ElseIf Sheet2.

Cells(i.Cells(i.Interior. 3).Value > 20 Then Sheet2. 3).Cells(i.ColorIndex = 9 ElseIf Sheet2. 3).ColorIndex = 12 End If i = i + 1 MsgBox i Loop End Sub .Interior.Sheet2.