campbell1093
New Member
- Joined
- Aug 27, 2024
- Messages
- 6
- Office Version
- 365
- Platform
- Windows
Hello all, I am working on a monthly tracker for work where I have a userform that allows the user to enter data. My last goal with this is to select a month tab based on entered data in the userform.
For context, right now I have to manually select the month I want to enter the data to, then activate my userform, and allow it to enter that way. I am trying to make VBA select the correct monthly tab based on the entered data and input the information there.
I can't attach a sample due to my admin restrictions, but I can try to attach my code. I'm guessing the relevant code would go somewhere with the "AddEntry" function of my code.
I am also open to suggestions and input on how to better this worksheet.
For context, right now I have to manually select the month I want to enter the data to, then activate my userform, and allow it to enter that way. I am trying to make VBA select the correct monthly tab based on the entered data and input the information there.
I can't attach a sample due to my admin restrictions, but I can try to attach my code. I'm guessing the relevant code would go somewhere with the "AddEntry" function of my code.
I am also open to suggestions and input on how to better this worksheet.
VBA Code:
Private Sub AddEntry_Click()
Dim msg As String
If CaseBox.Value = "" Then
CaseBox.SetFocus
CaseBox.BackColor = RGB(255, 125, 125)
Exit Sub
Else
End If
If ComplaintBox.Value = "" Then
ComplaintBox.SetFocus
ComplaintBox.BackColor = RGB(255, 125, 125)
Exit Sub
Else
End If
If OffenseBox.Value = "" Then
OffenseBox.SetFocus
OffenseBox.BackColor = RGB(255, 125, 125)
Exit Sub
Else
End If
If LevelSelect.Value = "" Then
LevelSelect.SetFocus
LevelSelect.BackColor = RGB(255, 125, 125)
Exit Sub
Else
End If
If ReportedBox.Value = "" Then
ReportedBox.SetFocus
ReportedBox.BackColor = RGB(255, 125, 125)
Exit Sub
Else
End If
If SuspectBox.Value = "" Then
SuspectBox.SetFocus
SuspectBox.BackColor = RGB(255, 125, 125)
Exit Sub
Else
End If
If DispositionBox.Value = "" Then
DispositionBox.SetFocus
DispositionBox.BackColor = RGB(255, 125, 125)
Exit Sub
Else
End If
If DDateBox.Value = "" Then
DDateBox.SetFocus
DDateBox.BackColor = RGB(255, 125, 125)
Exit Sub
Else
End If
If ActionBox.Value = "" Then
ActionBox.SetFocus
ActionBox.BackColor = RGB(255, 125, 125)
Exit Sub
Else
End If
msg = MsgBox("Are You Sure?", vbYesNo + vbQuestion, "Add Entry")
If msg = vbNo Then
Exit Sub
Else
End If
ActiveSheet.Select
Range("A1").End(xlDown).Offset(1, 0).Select
ActiveCell.Value = CaseBox.Value
ActiveCell.Offset(0, 1).Value = ComplaintBox.Value
ActiveCell.Offset(0, 2).Value = OffenseBox.Value
ActiveCell.Offset(0, 3).Value = LevelSelect.Value
ActiveCell.Offset(0, 4).Value = ReportedBox.Value
ActiveCell.Offset(0, 5).Value = SuspectBox.Value
ActiveCell.Offset(0, 6).Value = DispositionBox.Value
ActiveCell.Offset(0, 7).Value = DDateBox.Value
ActiveCell.Offset(0, 8).Value = ActionBox.Value
ActiveCell.Offset(0, 9).Value = AsOfBox.Value
CaseBox.Value = ""
ComplaintBox.Value = ""
OffenseBox.Value = ""
LevelSelect.Value = ""
ReportedBox.Value = ""
SuspectBox.Value = ""
DispositionBox.Value = ""
DDateBox.Value = ""
ActionBox.Value = ""
AsOfBox.Value = Date
End Sub