Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I am trying to populate a cell via vba based on the value of another
cell(s). For example, let's say: A1 contains a current inventory level of a part (say 12) B1 contains a minimum required level in inventory (say 10) C1 contains how many of a certain part I need (say 3) I have code that determines if A1-C1 is less than B1. If so, then D1 is populated with "Buy". If not, then the cell is populated with "Pull". My code works fine for this. So far so good. Here is the problem: I want to be able to flag any part labeled as "not inventory" in cell E1 as "Buy" as there is no data for the "in stock" or "minimum stock" values. So, here is my code: NOTE!!! I am using variables to step through the rows 1 by 1. So, the code you see before you is part of a larger For/Next loop. 'Populate Pull/Buy Cells Needed = Cells(RowNum, ColN5) - Cells(RowNum, ColN4) If Needed < Cells(RowNum, ColN6) * 0.9 _ Or If Cells(RowNumMin, ColPN).Value = "not inventory" Then Cells(RowNum, ColN7).Value = "Buy" Else Cells(RowNum, ColN7).Value = "Pull" End If The problem: When I added this line -- Or If Cells(RowNumMin, ColPN).Value = "not inventory" The portion of code that fills in "Buy" stops working. It simply no longer puts the value of "Buy" in ANY cell. If I take out the "Or..." code, it works fine. The part numbers are values that look like this 555-11-222 via a custom format. The "actual" value in the cell is 55511222. And of course there are several with the text "not inventory". If I change all of the "not inventory" cells to something like 99911222 and then change my "Or..." code to this: Or If Left(Cells(RowNumMin, ColPN).Value,1) < 5 Then the code works fine and I get "Buy" in the appropriate cells. Why can't my original code "see" the "not inventory" in the cells????? I should also note that I put in a message box show what the code thought was in Cells(RowNumMin, ColPN) and it completely skips "not inventory" cells! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Automatic Update of Dropdown List Box data | Excel Worksheet Functions | |||
Text formatting | Excel Worksheet Functions | |||
Find the cell value in excel by using vb code | Excel Discussion (Misc queries) | |||
Possible Lookup Table | Excel Worksheet Functions | |||
GET.CELL | Excel Worksheet Functions |