【发布时间】:2017-09-08 08:01:51
【问题描述】:
我试图让用户搜索多达 6 种不同类型的字符串(文本)。但是我已经尝试了最多 2 次,
问题
但我的代码只正确执行第一个搜索。但是,在第一个字符串之后的任何搜索都没有达到目标。
目标
代码的目标是在指定行中查找字符串,然后在该列中搜索大于零的值,如果是则复制整行。
Private Sub btnUpdateEntry_Click()
Dim StringToFind As String
Dim SringToFind2 As String
Dim i As Range
Dim cell As Range
StringToFind = Application.InputBox("Enter string to find", "Find string")
StringToFind2 = Application.InputBox("Enter string to find", "Find string")
With Worksheets("Skills Matrix")
Set cell = .Rows(1).Find(What:=StringToFind, LookAt:=xlWhole, _
MatchCase:=False, SearchFormat:=False)
If Not cell Is Nothing Then
For Each i In .Range(cell.Offset(1), .Cells(.Rows.Count, cell.Column).End(xlUp))
If IsNumeric(i.Value) Then
If i.Value > 0 Then
i.EntireRow.Copy
Sheets("Data").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial
End If
End If
Next i
Else
Worksheets("Data").Activate
MsgBox "String not found"
End If
End With
End Sub
谢谢
【问题讨论】: