(Solved) – Excel VBA multiple If’s shortcut

(solved)-–-excel-vba-multiple-if’s-shortcut

Im writing this VBA and come up with this multiple if code, im wondering if there’s a shortcut to shorten this one.

Private Sub CommandButton1_Click()
If Range("B15").Value = 6 Then
 MsgBox "Maximum Beams Reached (7)", vbCritical
    Exit Sub

End If
 Range("B15").Value = Range("B15").Value   1
      Columns(colNum & "D").Insert Shift:=xlDown
 Range("D3:D13").Borders(xlInsideHorizontal).LineStyle = xlContinuous
  Range("D3:D13").Borders(xlEdgeRight).LineStyle = xlContinuous

 If Range("B15").Value = 1 Then
  Range("D15").Value = "Beam Summary"
  Range("D16").Value = "  Concrete Volume"
  Range("D17").Value = "  Rebar Length"
  End If

 If Range("B15").Value = 1 Then
 Range("D3").Value = "Beam " & Range("B15").Value   1
 Else
     If Range("B15").Value = 2 Then
  Range("D3").Value = "Beam " & Range("B15").Value
  Range("E3").Value = "Beam " & Range("B15").Value   1
  Else
      If Range("B15").Value = 3 Then
  Range("D3").Value = "Beam " & Range("B15").Value - 1
  Range("E3").Value = "Beam " & Range("B15").Value
  Range("F3").Value = "Beam " & Range("B15").Value   1

 End If
 End If
End If


End Sub

CAN ANYONE HELP ME TO SHORTEN THIS IF’s CODE ?

Leave a Reply

Your email address will not be published. Required fields are marked *