Hi there,
I need help writing a macro that will highlight every 10th selection of same item from userform combo box. is that possible?
I need help writing a macro that will highlight every 10th selection of same item from userform combo box. is that possible?
VBA Code:
Private Sub ComboBoxProduct_change()
Dim m As String
'Convert date into Julian days
Dim awb As WorksheetFunction, JulianDt As String
Dim ws As Worksheet
Dim DateCell, ProdCell As Range
Dim DayCount, RowCell As Long
Set awb = Application.WorksheetFunction
JulianDt = awb.Text(awb.Days(Date, 1) - awb.Days(DateSerial(Year(Date), 1, 0), 1), "000")
m = FormSelectSht.ComboBoxProduct.Value
For Each ws In ThisWorkbook.Worksheets
If ws.Name = ComboBoxMachines.Value Then Exit For
Next ws
DayCount = 1
For RowCell = 5 To 200
If ws.Cells(RowCell, 1).Value = Date And ws.Cells(RowCell, 2) = ComboBoxProduct.Value Then DayCount = DayCount + 1
Next RowCell
FormSelectSht.TextBoxLot.Value = JulianDt + "-" + Format(Date, "yyyy") + "-" + m + "-" + Format(DayCount, "000")
End Sub