DataBlake
Well-known Member
- Joined
- Jan 26, 2015
- Messages
- 781
- Office Version
- 2016
- Platform
- Windows
So i'm trying to check if a key from one dictionary exists in another, and if it does to write the value/keys to sheets depending on some if statements
Loop through all the keys from dicLIVE
if that key exists in dicQTY, the key contains "^4", and and the dicQTY value is greater than 8 then
write text, write the diceBay value associated with the key, and write 1
if that key exists in dicQTY, the key DOES NOT contains "^4", and and the dicQTY value is greater than 8 then
write text, write the diceBay value associated with the key, and write 4
if that key DOES NOT exist in dicQTY, or the dicQTY value is less than 8
write text. write the diceBay value associated with the key, and write text
else end if
so far i have
to explain the dictionaries:
dicLIVE is live inventory. It consists of a part number and a listing number
dicQTY is the newest feed of inventory. It consists of a part number and a quantity
so if there is a listing that falls below 8 or no longer appears in the new inventory feed, it needs to be added to OOS
if the listing exists in the new inventory and is above 8 we need to write it to QTY. There are two kinds of part numbers that matter if a listing is live. One has "^4" and one does not.
its uhhhhhhhhhhhhhhh not working as intended, please help
Loop through all the keys from dicLIVE
if that key exists in dicQTY, the key contains "^4", and and the dicQTY value is greater than 8 then
write text, write the diceBay value associated with the key, and write 1
if that key exists in dicQTY, the key DOES NOT contains "^4", and and the dicQTY value is greater than 8 then
write text, write the diceBay value associated with the key, and write 4
if that key DOES NOT exist in dicQTY, or the dicQTY value is less than 8
write text. write the diceBay value associated with the key, and write text
else end if
so far i have
Code:
Sub oosNqty()
Dim oos As Worksheet
Dim qty As Worksheet
Dim ws As Worksheet
Dim x As Long, j As Long, i As Long
Set ws = Sheets("Description Helper")
Worksheets.Add After:=ws
Set oos = ActiveSheet
Worksheets.Add After:=ws
Set qty = ActiveSheet
x = 1
For Each Key In dicLIVE.Keys
x = x + 1
If dicQTY.exists(Key) And _
InStr(1, Key, "^4") > 0 And _
dicQTY(Key) >= 8 Then
qty.Range("A" & x).Value = "Revise"
qty.Range("B" & x).Value = dicLIVE(Key)
qty.Range("C" & x).Value = 1
ElseIf dicQTY.exists(Key) And _
InStr(1, Key, "^4") = 0 And _
dicQTY(Key) >= 8 Then
qty.Range("A" & x).Value = "Revise"
qty.Range("B" & x).Value = dicLIVE(Key)
qty.Range("C" & x).Value = 4
ElseIf not dicQTY.exists(Key) or _
dicQTY(Key) < 8 Then
oos.Range("A" & x).Value = "End"
oos.Range("B" & x).Value = dicLIVE(Key)
oos.Range("C" & x).Value = "Incorrect"
Else
End If
Next
End Sub
to explain the dictionaries:
dicLIVE is live inventory. It consists of a part number and a listing number
dicQTY is the newest feed of inventory. It consists of a part number and a quantity
so if there is a listing that falls below 8 or no longer appears in the new inventory feed, it needs to be added to OOS
if the listing exists in the new inventory and is above 8 we need to write it to QTY. There are two kinds of part numbers that matter if a listing is live. One has "^4" and one does not.
its uhhhhhhhhhhhhhhh not working as intended, please help