Vba 在If语句中使用来自单元格结果的动态“”

Vba 在If语句中使用来自单元格结果的动态“”,vba,excel,Vba,Excel,我使用单元格公式来确定VBA IF语句中是否需要使用符号 这是我创建的一个非常大的算法的一部分,该算法根据两边的直线方程绘制几何图案 零件确定要插入的形状是否在绘图区域内,绘图区域可以是任何形状和大小 我被卡住的部分: GreaterORLess=Sheetsshape.RangeL4.value'将是此单元格中的一个结果 LeftPos=LeftD+L+G*CountL'插入矩形的左上角位置 LineEq=Sty-确定LeftPos是否小于或>的边界线B/m'角度 我想您可以把它看作VBA I

我使用单元格公式来确定VBA IF语句中是否需要使用符号

这是我创建的一个非常大的算法的一部分,该算法根据两边的直线方程绘制几何图案

零件确定要插入的形状是否在绘图区域内,绘图区域可以是任何形状和大小

我被卡住的部分:

GreaterORLess=Sheetsshape.RangeL4.value'将是此单元格中的一个结果 LeftPos=LeftD+L+G*CountL'插入矩形的左上角位置 LineEq=Sty-确定LeftPos是否小于或>的边界线B/m'角度

我想您可以把它看作VBA If语句需要在If语句中连接,然后求值

GreaterORLess = Sheets("shape").Range("L4").value '(will either be a "<" or ">" result in this cell) 

LeftPos = LeftD + ((L + G) * CountL) 'Top Left position of rectangle being inserted

LineEq = (Sty - B) / m ' angle of boundary line to determine if LeftPos is < or > than

If (GreaterORLess = ">" And LeftPos > LineEq) Or  
   (GreaterORLess = "<" And LeftPos < LineEq) Then

    ActiveSheet.Shapes.AddShape(msoShapeRectangle, _
                      LeftD + ((l + g) * CountL), _
                      topd + (CountW * (W + g)), l, W).Select

End If
GreaterORLess = Sheets("shape").Range("L4").value '(will either be a "<" or ">" result in this cell) 

LeftPos = LeftD + ((L + G) * CountL) 'Top Left position of rectangle being inserted

LineEq = (Sty - B) / m ' angle of boundary line to determine if LeftPos is < or > than

If (GreaterORLess = ">" And LeftPos > LineEq) Or  
   (GreaterORLess = "<" And LeftPos < LineEq) Then

    ActiveSheet.Shapes.AddShape(msoShapeRectangle, _
                      LeftD + ((l + g) * CountL), _
                      topd + (CountW * (W + g)), l, W).Select

End If