R
RyanH
I am a novice to VBA and this is probably an easy fix, but I don't know. Is
it possible to use the WITH Statement with more than one Object? For example,
I have a Check Box that I use to Enable two Text Boxes in a UserForm. Here
is my code:
Private Sub chkChLtrs_Click()
With txbChLtrsDate
If chkChLtrs.Value = True Then
.Enabled = False
.Locked = True
Else
.Enabled = True
.Locked = False
End If
End With
With txbChLtrsHrs
If chkChLtrs.Value = True Then
.Enabled = False
.Locked = True
Else
.Enabled = True
.Locked = False
End If
End With
End Sub
Can this be shortened in anyway? For Example:
With txbChLtrsDate AND txbChLtrsHrs
' common code
End With
it possible to use the WITH Statement with more than one Object? For example,
I have a Check Box that I use to Enable two Text Boxes in a UserForm. Here
is my code:
Private Sub chkChLtrs_Click()
With txbChLtrsDate
If chkChLtrs.Value = True Then
.Enabled = False
.Locked = True
Else
.Enabled = True
.Locked = False
End If
End With
With txbChLtrsHrs
If chkChLtrs.Value = True Then
.Enabled = False
.Locked = True
Else
.Enabled = True
.Locked = False
End If
End With
End Sub
Can this be shortened in anyway? For Example:
With txbChLtrsDate AND txbChLtrsHrs
' common code
End With