Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default How to use If statement to read a value in a cell

I have a column of part numbers that look like this:

What you "see" after
###-##-### format is applied: What's actually in the
cell:
555-11-222 55511222
544-11-222 54411222
533-22-111 53322111
not inventory not inventory
511-33-444 511-33-444

I am trying to set up code that automatically determines if a part
should be "Pulled" from stock or "Bought" from the supplier based on
available stock. If the "Qty Req" makes the "Min" stock value fall
below 90% of the minimum, I should "Buy". Or, if it is "not inventory"
it should immediately be flagged as "Buy" because...it obviously is not
in stock!

I can do that in code as long as the value in part number is composed
of numbers. For the "not inventory" parts, my code simply "skips" over
the value.

The entire sheet looks something like this:
part number stock min Qty Req Pull/Buy
555-11-222 5 6 2
544-11-222 8 5 2
533-22-111 5 3 2
not inventory 2

511-33-444 7 6 2

My code looks like this:
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 code above will simply skip over the "not inventory" parts and
leave the "Pull/Buy" cell blank. If I change "not inventory" to
something like 999-11-222 and look for that in the code...it works.
What is wrong?

  #2   Report Post  
Posted to microsoft.public.excel.misc
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default How to use If statement to read a value in a cell

The code is a little over my head, but basically I see your "not inventory"
cell as not qualifying as "Needed", so the whole section is skipped. I would
think you would need to somehow change your structure so the "not inventory"
cell would qualify as "needed" so the "If Needed" section would work

I know it's not much help but maybe will help you see something you didn't
before..

Vaya con Dios,
Chuck, CABGx3



"Brady" wrote:

I have a column of part numbers that look like this:

What you "see" after
###-##-### format is applied: What's actually in the
cell:
555-11-222 55511222
544-11-222 54411222
533-22-111 53322111
not inventory not inventory
511-33-444 511-33-444

I am trying to set up code that automatically determines if a part
should be "Pulled" from stock or "Bought" from the supplier based on
available stock. If the "Qty Req" makes the "Min" stock value fall
below 90% of the minimum, I should "Buy". Or, if it is "not inventory"
it should immediately be flagged as "Buy" because...it obviously is not
in stock!

I can do that in code as long as the value in part number is composed
of numbers. For the "not inventory" parts, my code simply "skips" over
the value.

The entire sheet looks something like this:
part number stock min Qty Req Pull/Buy
555-11-222 5 6 2
544-11-222 8 5 2
533-22-111 5 3 2
not inventory 2

511-33-444 7 6 2

My code looks like this:
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 code above will simply skip over the "not inventory" parts and
leave the "Pull/Buy" cell blank. If I change "not inventory" to
something like 999-11-222 and look for that in the code...it works.
What is wrong?


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default How to use If statement to read a value in a cell

The "Needed" variable is not part of the "Or" if statement.

Secondly, I would first have to be able to read the value in the cells
marked with "not inventory"...which is exactly what I can't seem to do,
to determine some action for cells with that value.

This must be some kind of data mismatch and for the life of me I just
can't see it.

Thanks anyway for the response. I'll keep plugging away at it.


CLR wrote:
The code is a little over my head, but basically I see your "not inventory"
cell as not qualifying as "Needed", so the whole section is skipped. I would
think you would need to somehow change your structure so the "not inventory"
cell would qualify as "needed" so the "If Needed" section would work

I know it's not much help but maybe will help you see something you didn't
before..

Vaya con Dios,
Chuck, CABGx3


  #4   Report Post  
Posted to microsoft.public.excel.misc
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default How to use If statement to read a value in a cell

Sorry, my bad..........perhaps ElseIf would work better than OrIf.........

Vaya con Dios,
Chuck, CABGx3



"Brady" wrote:

The "Needed" variable is not part of the "Or" if statement.

Secondly, I would first have to be able to read the value in the cells
marked with "not inventory"...which is exactly what I can't seem to do,
to determine some action for cells with that value.

This must be some kind of data mismatch and for the life of me I just
can't see it.

Thanks anyway for the response. I'll keep plugging away at it.


CLR wrote:
The code is a little over my head, but basically I see your "not inventory"
cell as not qualifying as "Needed", so the whole section is skipped. I would
think you would need to somehow change your structure so the "not inventory"
cell would qualify as "needed" so the "If Needed" section would work

I know it's not much help but maybe will help you see something you didn't
before..

Vaya con Dios,
Chuck, CABGx3



Reply
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
Cell References [email protected] Excel Discussion (Misc queries) 2 November 15th 06 11:37 PM
Compiling macro based on cell values simonsmith Excel Discussion (Misc queries) 1 May 16th 06 08:31 PM
VBA Command to Look at cell in an If statement Wolf New Users to Excel 3 December 27th 04 11:27 PM
Using Jet to read excel file returns blank for last cell - sometim Ron Excel Discussion (Misc queries) 1 December 9th 04 08:21 AM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 04:10 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"