Materi Perkuliahan

Menghitung Banyak Peluang VBA for Excel

Dipublikasikan pada : 29 Januari 2020.

Private Sub CommandButton1_Click()
Dim a As Integer
Dim b As Integer
a = Range(“B3”)
b = Range(“D3”)
For i = a To b
Range(“A” & 4 + i – a) = i
Next i
End Sub

Private Sub CommandButton2_Click()
Dim a As Integer
Dim b As Integer
a = Range(“B3”)
b = Range(“D3”)
K = 0
For j = a To b
c = Left(j, 1)
d = Mid(j, 2, 1)
e = Right(j, 1)
If e <> d And e <> c And d <> c Then
K = K + 1
Range(“A” & 4 + j – a).Interior.Color = vbYellow
Else
Range(“A” & 4 + j – a).Interior.Color = vbWhite
End If
Range(“C4”) = K
Next j
End Sub

Private Sub CommandButton3_Click()
Range(“A4:A10000”).Clear
Range(“C4”) = “”
End Sub

id_IDIndonesian