So here is my problem section of code (I have added the msgbox as a test line) It is within a much larger with statement for the worksheet.
so my sheet is a load of parts and the named range level is where in an assembly tree they go. this is suposed to make sure any assembly lines are labeled A and parts are labeled D
for levels over 1 it works fine however if part.value is 0 and the cell below is 1 (usually the top level of the tree) it reads as false.
I can't figure out why. I have watched the part.value expression and did notice that 0 is stored as a variant/string while other numbers are stored as variant/double but when I tested that with the msgbox line it ran fine.
I could throw in an "or part.value =0" to the if statement but would rather search for a less clunky solution first.
Code:
For Each part In Range("Level").Cells
If "0" < 1 Then MsgBox part.Value & " " & .Cells(part.Row + 1, part.Column).Value
If part.value < .Cells(part.Row + 1, part.Column).Value Then _
.Cells(part.Row, Range("Part_Type").Column) = "A" Else: _
.Cells(part.Row, Range("Part_Type").Column) = "D"
Next part
for levels over 1 it works fine however if part.value is 0 and the cell below is 1 (usually the top level of the tree) it reads as false.
I can't figure out why. I have watched the part.value expression and did notice that 0 is stored as a variant/string while other numbers are stored as variant/double but when I tested that with the msgbox line it ran fine.
I could throw in an "or part.value =0" to the if statement but would rather search for a less clunky solution first.