chriscorpion786
Board Regular
- Joined
- Apr 3, 2011
- Messages
- 112
- Office Version
- 365
- Platform
- Windows
Hi,
Im using the VBA dictionary to make a summary report by salesrep for quantity and value. The problem is if I put an IF condition testing for the year to be 2017, one of the values comes wrong. If I remove the IF condition the code works fine and gives all the correct results. Is there a problem using an IF condition like below. How can i modify the code to test a condition.
Rgds,
Mustafa
Im using the VBA dictionary to make a summary report by salesrep for quantity and value. The problem is if I put an IF condition testing for the year to be 2017, one of the values comes wrong. If I remove the IF condition the code works fine and gives all the correct results. Is there a problem using an IF condition like below. How can i modify the code to test a condition.
Code:
For x = 2 To rng.Rows.Count
If sht.Cells(x, 1).value = 2017 Then
salesrep = sht.Cells(x, 4).value
qty = sht.Cells(x, 10).value
value = sht.Cells(x, 9).value
End If
dictqty(salesrep) = dictqty(salesrep) + qty
dictvalue(salesrep) = dictvalue(salesrep) + value
Next x
x = 2
For Each key In dictqty
Cells(x, 1).value = key
Cells(x, 2).value = dictqty(key)
Cells(x, 3).value = dictvalue(key)
x = x + 1
Next key
Rgds,
Mustafa
Last edited by a moderator: