'How can I print a certain string depending on the row value in Excel using VBA?
I have three columns A, B and C in the excel sheet which contain some dimensions:

I need to calculate and print the volume(length x width x height) in column E. Once I have the volume, based on the value I will need to label it as Small, Medium or Large in Column F.
I need to do this using VBA.
P.S: This is just sample data, actual data will be a lot more so the range needs to be dynamic.
I tried the following piece of code but I am getting error on the line marked with '*'. The part where I need to calculate the volume is working fine but the labelling logic is the problem. The error I am getting is 'Type Mismatch'.
Sub test()
Dim LR
LR = Range("B" & Rows.Count).End(xlUp).Row
Range("E3:E" & LR).Formula = "=B3*C3*D3"
Range("E3:E" & LR).Value = Range("E3:E" & LR).Value
*If Range("E3:E" & LR).Value < 1000000 Then
Range("F3:F" & LR).Value = "Small"
ElseIf Range("E3:E" & LR).Value >= 1000000 And Range("E3:E" & LR).Value <= 9000000 Then
Range("F3:F" & LR).Value = "Medium"
Else
Range("F3:F" & LR).Value = "Large"
End If
End Sub
I am new to VBA so not sure what am I doing wrong. Please can someone help me with this.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
