1. I'd change the <<<<<< marked line. I'm not sure but VBA might interpret that as (50 <= Width) as = True and (True < 100)
2. All three tests have (Grith <= 165) so I'm not surprised that Grith = 180 fails
Option Explicit
Sub ParcelDelivery1()
Dim Weight As Double, Lnth As Double, Width As Double, Height As Double, Girth As Double
Dim TypeA As Boolean, TypeB As Boolean, TypeC As Boolean
'l am gonna use the numbers such that i get type C.
'So lets say weight is 100 lbs , length is 100 , bread is 20 and height is 20 .
'So girth is 180. This should qualify for C type .
'However, on running the code , I get B type. What am i doing wrong?
Weight = 100 ' Me.TextBox31.Value
Lnth = 100 ' Me.TextBox32.Value
Width = 20 ' Me.TextBox33.Value
Height = 20 ' Me.TextBox34.Value
Girth = Lnth + (2 * (Width + Height))
If (Weight < 50) And (Girth <= 165) Then
TypeA = True
Else
TypeA = False
End If
If (50 <= Weight) And (Weight < 100) And (Girth <= 165) Then ' <<<<<<<<<<<<<<<<<<<<<<<<<
TypeB = True
Else
TypeB = False
End If
If (100 <= Weight) And (Girth <= 165) Then
TypeC = True
Else
TypeC = False
End If
If TypeA Then
MsgBox "Type A"
' Dim pdA As Range
' Set pdA = ActiveDocument.Bookmarks("t1").Range
' pdA.Text = "A"
ElseIf TypeB Then
MsgBox "Type B"
' Dim pdb As Range
' Set pdb = ActiveDocument.Bookmarks("t1").Range
' pdb.Text = "B"
ElseIf TypeC Then
MsgBox "Type C"
' Dim pdc As Range
' Set pdc = ActiveDocument.Bookmarks("t1").Range
' pdc.Text = "C"
End If
End Sub