【发布时间】:2017-04-18 12:33:08
【问题描述】:
如果满足 2 个条件,则通过 Sheet1 搜索:
文本提示用户InputBox DATE(A 列)和字母“X”(V 列)是一个常数。如果满足这两个条件,则将整行复制并粘贴到 Sheet2。
这是我以前工作中的整数搜索:
Private Sub CommandButton5_Click()
Dim strsearch As String, lastline As Integer, tocopy As Integer
'find what date? find other value?
strsearch = CStr(InputBox("enter the string to search for"))
lastline = Range("A65536").End(xlUp).Row
j = 1
For i = 1 To lastline
For Each c In Range("A" & i & ":V" & i)
If InStr(c.Text, strsearch) Then
tocopy = 1
End If
Next c
'Copy the current row
If tocopy = 1 Then
Rows(i).Copy Destination:=Sheets("MONTH_END").Rows(j)
j = j + 2
End If
tocopy = 0
Next i
End Sub
【问题讨论】:
-
用户输入“日期”要查找的
InputBox在哪里?它不会出现在您添加的代码中