Selasa, 19 Mei 2015

Pencabangan 2 : Select Case

Sub Sheet2_RoundedRectangle1_Click()
ActiveCell.Offset(0, -1).Select
Nilai = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
If Nilai = 0 Then
    ActiveCell.Value = "Nol"
Else
    If Nilai = 1 Then
        ActiveCell.Value = "Satu"

Program Kotak Stop


Sub KeBawah_Button1_Click()

If Range("C3") = "" And Range("C4") = "" Then
    Range("C3") = ActiveCell.Column + 1
    Range("C4") = ActiveCell.Row + 1
Else
    If ActiveCell.Column = 1 And ActiveCell.Row = 1 Then
        Range("C3") = Range("C3") - 1
        Range("C4") = Range("C4") - 1
    Else
 
    End If
End If

Program Kotak

If Range("C3") = "" And Range("C4") = "" Then
    Range("C3") = ActiveCell.Column + 1
    Range("C4") = ActiveCell.Row + 1
Else
    If ActiveCell.Column = 1 And ActiveCell.Row = 1 Then
        Range("C3") = Range("C3") - 1
        Range("C4") = Range("C4") - 1
    Else
 
    End If
End If

If ActiveCell.Column > 1 And ActiveCell.Row > 1 And ActiveCell.Column < Range("C3") Then
    ActiveCell.Offset(0, -1).Select
    ActiveCell.Interior.ColorIndex = ActiveCell.Column
Else
    If ActiveCell.Row > 1 And ActiveCell.Column < Range("C3") Then
        ActiveCell.Offset(-1, 0).Select
        ActiveCell.Interior.ColorIndex = ActiveCell.Row
    Else
        If ActiveCell.Column < Range("C3").Value Then
            ActiveCell.Offset(0, 1).Select
            ActiveCell.Interior.ColorIndex = ActiveCell.Column
     
        Else
            ActiveCell.Offset(1, 0).Select
            ActiveCell.Interior.ColorIndex = ActiveCell.Row
        End If
    End If
End If