1. Active Worksheet
Write this 3 short programs in one module, and check the result.
Sub Program1()
Range("A1:A10") = 12
End Sub
'...............................................
Sub Program2()
Sheets("Arkusz2").Select
Range("B1:B10") = 12
End Sub
'...............................................
Sub Program3()
ActiveSheet.Range("A1:A10") = 12
ActiveSheet.Range("B1:B10") = 22
End Sub
What’s the difference ?
2. Declering the amount for the variable.
As you might already know while we declaring our variables we can byt the way decide how much chatarcters it should contains with this simple small difference:
Sub LenExample1()
Sheets("Arkusz1").Select
Range("A1") = "Login"
Range("B1") = "Password"
Dim L As String * 8
Dim P As String * 5
L = 123456789
P = 123456789
Range("A2") = L
Range("B2") = P
End Sub
3. Login and Password definition
Sub Program2()
Sheets("Arkusz1").Select
Range("A1") = "Login"
Range("B1") = "Password"
If Len(Range("A2")) = 8 Then
MsgBox "Login correct"
Else: MsgBox "Logins should contains 8 characters"
End If
If Len(Range("B2")) < 6 Then
MsgBox "Password should contains at least 6 characters:
1 or more Numeric and 1 special sign"
Else: MsgBox "Password accepted"
End If
End Sub