I want to bring our freight price in workbook 1, Cell B14.
The freight price varies based on freight weight:
- If the freight weight is less than 45 kg, freight price is 55.00 HKD
- If the weight is greater than 45 kg, freight price is 47.00 HKD
- If the weight is greater than 100 kg, freight price is 29,50 HKD
The VBA I have so far is listed below, but I get the following error: statement invalid outside Type block
. How to make this work?
Public Function freightrate()
Weight As Double
freightrate As Double
Weight = Cells(B, 8).Value
freightrate = Cells(B, 14).Value
If Weight < 45 Then
freightrate = 55
ElseIf Weight > 45 < 100 Then
freightrate = 47
ElseIf Weight > 100 < 300 Then
freightrate = 29,50
End If
End Function