我试图在从单元格D14开始的所有单元格中首次出现打开括号后删除所有单词。我不断提出一个Object Required错误,并且不确定问题出在哪里。
Dim startRow As Integer
Dim pos_of_parenth As Integer
Dim resultString as String
startRow = 15
With Windows(NewTemplateName)
.Activate
.ActiveSheet.Range("D" & startRow).Select
Do While .ActiveSheet.Range("D" & startRow).Value <> ""
resultString = ""
pos_of_parenth = InStr(1, ActiveSheet.Range("D" & startRow).Text, "(", CompareMethod.Text)
resultString = Left(.ActiveSheet.Range("D" & startRow).Value, pos_of_parenth)
startRow = startRow + 1
Loop
End With
答案 0 :(得分:2)
将CompareMethod.Text
更改为VbCompareMethod.vbTextCompare
答案 1 :(得分:0)
我最终还是通过完全摆脱“CompareMethod.Text”
来修复它