Code:
Private Sub MachineOptionsBox_Change()
Dim priceCell As Range
Dim imprCell As Range
Dim selcItem As Long
Dim sRowN As Integer
Dim sCol As Integer
Dim ws As Worksheet
Set ws = Sheets("*Sheet Name*")
sRowN = 0
For Each priceCell In ws.Range("C1:C5000")
If priceCell.Value = "Agents View" Then
For selcItem = 0 To Me.MachineOptionsBox.ListCount - 1
If priceCell.Offset(, -2).Value = MachineTypeBox.Value Then
If priceCell.Offset(, 3).Value = CLng(Me.MachineOptionsBox.Selected(selcItem)) Then
sRowN = priceCell.Row
Exit For
End If
End If
Next selcItem
End If
If sRowN > 0 Then
Exit For
End If
Next priceCell
For Each imprCell In ws.Range("BF4:BY4")
If imprCell.Value = CLng(NoOfImpressionsBox.Value) Then
sCol = imprCell.Column
Me.AgentCostBox.Value = Me.AgentCostBox.Value + Cells(sRowN, sCol).Value
End If
Next imprCell
AgentCostBox = Format(AgentCostBox, "£#,##0.00")
Hi guys,
I've got the basics of this code, it's a bit buggy at the moment. I'm trying to make so that when a item is selected it searching for the price via the numerous if and for each statements, and adds it to the CostBox.
When deselected it takes it away from the cost box, the current problems i'm having is trying to go through the combo box and match the cell value in offset 3. Also another problem i am having is that i do not know how to dynamically add to the price box, i can always add but never take away when selected. I imagine i need some sort of 'While' statement?
This may be hard to understand without and example, please let me know if you need more information.
Thanks,