LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default Cell value not recognized by code.

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic Update of Dropdown List Box data Rajat Excel Worksheet Functions 4 March 8th 12 05:09 PM
Text formatting Kace Excel Worksheet Functions 1 September 18th 06 08:28 PM
Find the cell value in excel by using vb code Michael Excel Discussion (Misc queries) 5 June 14th 05 01:24 PM
Possible Lookup Table Karen Excel Worksheet Functions 5 June 8th 05 09:43 PM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 01:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"