文本以“x”开头

我想在我的代码中将单词“K”更改为以“x”开头的单元格中的单词,但我已经尝试过了。 而且它不工作。

注意:t1 =列F t2 =列G

如instr(st,“+10”),这意味着如果单词列的st有“+10”的意思是真正的权利,但现在我需要单词H列(st平均列H)+10和列F单词必须以“x”开始

Dim a As Integer Dim b As Integer Dim c As Integer Dim d As Integer Application.ScreenUpdating = False a = Cells(Rows.Count, "C").End(xlUp).Row For b = 1 To a If IsNumeric(Cells(b, "C").Value) Then st = Cells(b, "G").Value t1 = Cells(b, "F") t2 = Cells(b, "H") v1 = 1.72 v2 = 2.1 v3 = 1.9 v4 = 1.8 v5 = 2 If InStr(st, "+10") > 0 And t1 = "K" Then Cells(b, "E") = v1 Cells(b, "J") = v2 ElseIf InStr(st, "-10") > 0 And t1 = "K" Then Cells(b, "E") = v3 Cells(b, "J") = v3 ElseIf InStr(st, "-5") > 0 And t1 = "K" Then Cells(b, "E") = v5 Cells(b, "J") = v4 ElseIf t1 = "K" Then Cells(b, "E") = v4 Cells(b, "J") = v5 ElseIf InStr(st, "+10") > 0 And t2 = "K" Then Cells(b, "J") = v1 Cells(b, "E") = v2 ElseIf InStr(st, "-10") > 0 And t2 = "K" Then Cells(b, "J") = v3 Cells(b, "E") = v3 ElseIf InStr(st, "-5") > 0 And t2 = "K" Then Cells(b, "J") = v5 Cells(b, "E") = v4 ElseIf t2 = "K" Then Cells(b, "J") = v4 Cells(b, "E") = v5 ElseIf InStr(st, "-10") > 0 Then Cells(b, "J") = v3 Cells(b, "E") = v3 Else Cells(b, "E") = 0 Cells(b, "J") = 0 End If End If Next Application.ScreenUpdating = True End Sub 

在这里input图像说明

在这里input图像说明

我不知道我是否理解你,但是…你在寻找一种方法来testingF列的第一个字符吗? 然后:

 If InStr(Cells(b, "H"), "-10") > 0 And left(Cells(b, "F"), 1) = "x" Then