Hi there,
So currently I'm working on spreadsheet that will gather data from userform combo box. Each time data is entered from userform it is entered into new row that is entered at row 5. I want help with how do I code so that every 10th product selected in column B the 10th one is highlighted. Because 10th numbered product is on will be on the row 5 when which is the top row i m not sure how to do it. Also there might be different product selected in between so the product selection is not going to be 10 same product in row. I hope this description makes sense.
So currently I'm working on spreadsheet that will gather data from userform combo box. Each time data is entered from userform it is entered into new row that is entered at row 5. I want help with how do I code so that every 10th product selected in column B the 10th one is highlighted. Because 10th numbered product is on will be on the row 5 when which is the top row i m not sure how to do it. Also there might be different product selected in between so the product selection is not going to be 10 same product in row. I hope this description makes sense.
VBA Code:
Public SuppressChangeEvent As Boolean
Sub Button()
Dim i As Integer
Dim wb As Workbook: Set wb = ThisWorkbook
Dim ws As Worksheet
Dim WSheet As Worksheet
Dim LastRow As Long
Dim Row As Integer
Dim Lot As String
Dim Error As Boolean
Error = False
If FormSelectSht.TextBoxOperator1 = "" Then
MsgBox "Please fill Operator Box"
Error = True
End If
If FormSelectSht.ComboBoxMachines = "" Then
MsgBox "Please Select Machine"
Error = True
End If
If FormSelectSht.ComboBoxPowder = "" Then
MsgBox "Please Select Powder"
Error = True
End If
If FormSelectSht.ComboBoxProduct = "" Then
MsgBox "Please Select Product"
Error = True
End If
If FormSelectSht.CBCrane = False Then
MsgBox " Is the Crane off?"
Error = True
End If
If FormSelectSht.CBVent = False Then
MsgBox " Is the Vent on?"
Error = True
End If
If Error Then
SuppressChangeEvent = True
Exit Sub
Else
SuppressChangeEvent = False
End If
For Each ws In wb.Sheets
If ws.Name = FormSelectSht.ComboBoxMachines.Value Then Set WSheet = ws
Next ws
WSheet.Unprotect "Roto"
With WSheet
.Activate 'activating the sheet
.Range("A5").EntireRow.Insert (xlDown)
.Range("A5").EntireRow.ClearFormats 'Clear all formats from row 5
.Range("A5:Q5").Font.Size = 14 'Increase font size
'Insert a new row at 5 and shift everything down
.Range("A5").Value = Date 'Insert date at A5
.Range("B5").Value = FormSelectSht.ComboBoxProduct.Value 'Insert Combobox value at B5
' .Range("C5") = JulianDt(Date)
.Range("C5").Value = FormSelectSht.TextBoxOperator1.Value
.Range("D5").Value = FormSelectSht.TextBoxOperator2.Value
.Range("E5").Value = FormSelectSht.TextBoxLot.Value
.Range("I5").Value = FormSelectSht.CBVent.Value
.Range("G5").Value = Time 'insert time at G5
.Range("H5").Value = FormSelectSht.CBCrane.Value
.Range("J5").Value = FormSelectSht.ComboBoxPowder.Value
End With
With WSheet.Range("L5").Validation
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="Accept,Reject"
.IgnoreBlank = True
.InCellDropdown = True
.ShowInput = True
.ShowError = True
End With
With Rows("5:5")
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=$L$5=""Reject"""
.FormatConditions(1).Interior.Color = 255
.FormatConditions(1).StopIfTrue = False
End With
FormSelectSht.ComboBoxProduct.Value = ""
FormSelectSht.TextBoxLot.Value = ""
WSheet.Protect "Roto"