How to do a Select Case with Left function in VBA?

走远了吗. 提交于 2020-01-16 07:49:10

问题


I'm trying to do a Select Case with Left function (contain(text in the cell) would be better but I don't know how to do that) but wasn't able to figure out how to do that.

I tried the following:

Sub siteadd()
    Dim x
    Dim Pl
    Dim Li

    Sheets("ort").Select
    Columns("F:F").Select
    Selection.TextToColumns Destination:=Range("F1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 2), TrailingMinusNumbers:=True

    NumRows = cells(Rows.Count, "j").End(xlUp).Row
    For x = 2 To NumRows
        Li = cells(x, 6).Value
        Pl = cells(x, 40).FormulaR1C1 = "=Left(RC[40], 12)"

        Select Case Li
            Case "#N/A"
                Select Case Pl
                    Case "asc aite Aad"
                        cells(x, 6).Value = "B"
                End Select
        End Select
    Next x
End Sub

来源:https://stackoverflow.com/questions/36574574/how-to-do-a-select-case-with-left-function-in-vba

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!