scottrssll
New Member
- Joined
- Jan 8, 2016
- Messages
- 11
Hello,
I'm currently building a disciplinary report log for work. The design of the log is simple; I have a table in Sheet 1 with rows corresponding to employee names. Each column represents a general category of possible infractions (e.g. safety; cell phone usage; failure to comply with procedures). I want to be able to click a cell to see and input specific infraction data (Date, Time, Supervisor), have it save to a database, and have the cell change format relative to the number of infractions (3 being most severe) with a message that pops up after 3 infractions asking if the employee was counselled and if that cell should be reset.
So far, I have this formula for the cells, which I don't like, to set the reference cells for the data and to offer a quick status message. I would prefer if the cells changed from Green, to Yellow, to Orange, to Red:
=IF(AND(ISTEXT(Sheet2!A1),ISTEXT(Sheet2!A2),ISTEXT(Sheet2!A3)),"WRITE UP","GOOD")
For the inputbox and msgbox aspect, I've been using Visual Basic, and I'm struggling greatly. The Code won't work at all and is missing the function to display the current infraction data. Furthermore, if I continue with the code as it is I will have to write the entire program over and over for every cell. But, since the cells have to reference a specific employee and specific category of violation, I don't know of a better way using VisualBasic. Maybe incorporating pull down menus or some other object might be more effective.
Please help! I'm desperate! Here's the code so far:
I'm currently building a disciplinary report log for work. The design of the log is simple; I have a table in Sheet 1 with rows corresponding to employee names. Each column represents a general category of possible infractions (e.g. safety; cell phone usage; failure to comply with procedures). I want to be able to click a cell to see and input specific infraction data (Date, Time, Supervisor), have it save to a database, and have the cell change format relative to the number of infractions (3 being most severe) with a message that pops up after 3 infractions asking if the employee was counselled and if that cell should be reset.
So far, I have this formula for the cells, which I don't like, to set the reference cells for the data and to offer a quick status message. I would prefer if the cells changed from Green, to Yellow, to Orange, to Red:
=IF(AND(ISTEXT(Sheet2!A1),ISTEXT(Sheet2!A2),ISTEXT(Sheet2!A3)),"WRITE UP","GOOD")
For the inputbox and msgbox aspect, I've been using Visual Basic, and I'm struggling greatly. The Code won't work at all and is missing the function to display the current infraction data. Furthermore, if I continue with the code as it is I will have to write the entire program over and over for every cell. But, since the cells have to reference a specific employee and specific category of violation, I don't know of a better way using VisualBasic. Maybe incorporating pull down menus or some other object might be more effective.
Please help! I'm desperate! Here's the code so far:
Code:
[/COLOR]
[COLOR=#333333]Option Explicit[/COLOR]
[COLOR=#333333]Sub TransgressionLog_Click(ByVal Target As Range)[/COLOR]
[COLOR=#333333] If Selection.Count = 1 Then[/COLOR]
[COLOR=#333333] If Not Intersect(Target, Range("D4")) Is Nothing Then[/COLOR]
[COLOR=#333333] If IsText(Sheet2!D1) And IsText(Sheet2!D2) And IsText(Sheet2!D3) Then[/COLOR]
[COLOR=#333333] Response = MsgBox("Has the counseling been completed?", vbYesNo, "Reset Counseling")[/COLOR]
[COLOR=#333333] If Response = msgboxresult.yes Then[/COLOR]
[COLOR=#333333] Sub sbClearCellsOnlyData()[/COLOR]
[COLOR=#333333] Range("Sheet2!d1:Sheet2!d3").ClearContents[/COLOR]
[COLOR=#333333] End Sub[/COLOR]
[COLOR=#333333] Else[/COLOR]
[COLOR=#333333] Response = MsgBox("Councelling Must Be Completed To Reset Strikes", vbOKOnly, "Reset Counseling")[/COLOR]
[COLOR=#333333] End If[/COLOR]
[COLOR=#333333] Else[/COLOR]
[COLOR=#333333] Sub cmdAddData_Click()[/COLOR]
[COLOR=#333333]
Dim strTransgression$[/COLOR]
[COLOR=#333333] Dim sw1 As Boolean
[/COLOR][COLOR=#333333] strTransgression = InputBox("Please Describe the Infraction", , "Transgression Report")[/COLOR]
[COLOR=#333333] With Sheets("2")[/COLOR]
[COLOR=#333333] lngLstRow = .UsedRange.Rows.Count + .UsedRange.Row[/COLOR]
[COLOR=#333333] .Range("d1:d3" & lngLstRow).Value = strUserName[/COLOR]
[COLOR=#333333] End With[/COLOR]
[COLOR=#333333] MsgBox "Transgression Successfully Added!", _[/COLOR]
[COLOR=#333333] vbExclamation + vbOKOnly, _[/COLOR]
[COLOR=#333333] "Added!"[/COLOR]
[COLOR=#333333] End If[/COLOR]
[COLOR=#333333] End Sub[/COLOR]
[COLOR=#333333] End If[/COLOR]
[COLOR=#333333] End If[/COLOR]
[COLOR=#333333] End If[/COLOR]
[COLOR=#333333]End Sub[/COLOR]
[COLOR=#333333][Code/][/COLOR]