View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Brady Brady is offline
external usenet poster
 
Posts: 10
Default Cell value not recognized by code.

Hi there Sandy,

Nice to meet a fellow Mann.

I changed the code as you suggested below (I had already tried it
albeit without the Trim statement). It still does not work. It simply
skips any cells with "not inventory".

I don't get it.

Thanks for the reply and best wishes on your new life!

Sandy Mann wrote:
Brady,

As Ian said you can't use IF like that, in fact my XL 97 highlighted that
line in red indicating a syntax error

I altered your code by simply removing the second IF and it worked for me.
It is, however, case sensitive and so, unlike a worksheet function it would
not find
"Not Inventory" so I wrapped it in UCase and, in case the user adds a
trailing space, I added a Trim as well:

'Populate Pull/Buy Cells
Needed = Cells(RowNum, ColN5) - Cells(RowNum, ColN4)
If Needed < Cells(RowNum, ColN6) * 0.9 _
Or UCase(Trim(Cells(RowNumMin, ColPN).Value)) = "NOT INVENTORY"
Then
Cells(RowNum, ColN7).Value = "Buy"
Else
Cells(RowNum, ColN7).Value = "Pull"
End If

Note that neither the UCase nor the Trim changes the entry in the worksheet.

Personally when I was at work, (I retired on Monday), I often unsed event
code to change, say, a user entry of "NI" into "Not Inventory" to ensure
that users were not making errors in entering data into the cell when I was
going to searching for an exact entry.
--
HTH

Sandy
Retired from Work
But hopefully not from Life


with @tiscali.co.uk