我想将代码中的单词“ 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
我不确定我是否了解您,但是...您是否正在寻找一种方法来测试F列的第一个字符?然后:
If InStr(Cells(b, "H"), "-10") > 0 And left(Cells(b, "F"), 1) = "x" Then
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句