我还是VBA的新手,到目前为止还找不到任何使用搜索功能的解决方案。 问题: 我有(在这种情况下,十张)一行超过500单元格包含5-7个字的字符串。 现在我需要删除搜索到的单词不是最后一个单词的所有列,但是该单词在字符串中不同位置的所有单元格(行中)。 我尝试这样做:根据字符串中字符的位置删除列
Dim examinee As Variant
Dim cell As Range
Dim word As String
Dim myCell As String
examinee = InputBox("How many sheets?")
word = InputBox("Looking for?")
For A = 1 To examinee
Sheets("sheet" & A).Select
On Error Resume Next
Range("A3", Range("A3").End(xlToRight)).Select
For Each Cell In Selection.Cells
myCell = Right(Cell, Len(Cell) - (InStrRev(Cell, " ") - 1))
MsgBox myCell ' just to be sure the word is found
If myCell Like word Then
Selection.Cells.Bold = False
Else
Delete.Column
End If
Next Cell
Next
我能找到&辨别单词和“如果”工作正常,到目前为止,只是什么也没有发生选定单元格和列并没有被删除。 随着一些更改,我只能删除整行,但它不是我所需要的。 任何帮助appriciated。 Thx提前。
谢谢,效果很好。对我来说,在这里学习很多新东西。 – Heinz