Code:
Hi all,
My code below is for a checkbox in a userform.
When I load a manager and click the button, it saves a "flight risk" entry to their row in the database.
The problem is, when I close and re-open the userform for the same person, the tick disappears even though I already saved them as flight risk.
In other words, if someone is already flight risk, the tick on the checkbox should appear.
Otherwise I have no indication whether if I have previously marked the person as flight risk.
Private Sub CheckBox1_Click()
Dim FindString As String
Dim Rng As Range
FindString = Range("e11").Value
If Trim(FindString) <> "" Then
With Sheets("manager 1").Range("f:f")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
.Goto Rng, False
'End With
With ActiveCell
.Offset(0, 45).Value = "flightrisk"
End With
'With Application
.EnableEvents = True
.Calculation = xlCalculationAutomatic
'MsgBox "Comment Saved"
'Else
End With
Sheets("one-pager profile").Select
MsgBox "Saved as Flight-risk"
' Call ViewManager1
Application.ScreenUpdating = True
End If
'End With
End With
End If
End If
If CheckBox1.Value = False Then
If Trim(FindString) <> "" Then
With Sheets("manager 1").Range("f:f")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
.Goto Rng, False
'End With
With ActiveCell
.Offset(0, 45).Value = ""
End With
'With Application
.EnableEvents = True
.Calculation = xlCalculationAutomatic
'MsgBox "Comment Saved"
'Else
End With
Sheets("one-pager profile").Select
MsgBox "Removed Flight-risk"
' Call ViewManager1
Application.ScreenUpdating = True
End If
'End With
End With
End If
End If
End Sub