An Introduction to VBA :- Third Step to VBA : Write VBA Code


Worksheets("sheet1").Activate 

Range("A1:A10").ClearContents

For i = 1 To 10

    Range("A" & i) = i ^ 2

Next

Range("A1:A10").Font.Bold = True

For Each cl In Range("A1:A10")

    If cl.Value < 25 Or cl.Value> 75 Then

        cl.Font.Italic = True

 Else

        cl.Font.Underline = True

    End If

Next

Msgbox“All done”

1)Make sheet1 active
2)Clear range A1:A10
3)Type 1,4,9,…100 in to range A1, A2, … A10
4)Set font to bold for all cells in the range
5)Make cell italic if the cell’s value is <25 or >75, otherwise underline
6)Display message “All done”

Comments

Popular posts from this blog

50 Excel VBA Oral Interview Questions