请完成此代码。
我想搜索“#34;日期:"在所有工作表(sheet2到工作表...)中,如果找到,请将值复制到sheet1
例如:如果找到单词" date:"在sheet2列A1中,然后复制A2值并粘贴到sheet1列A1。将sheet3复制并粘贴到sheet1列B1。按顺序处理
Sub help()
Dim SearchString As String
Dim SearchRange As Range, cl As Range
Dim ws As Worksheet
SearchString = "Date :"
For Each ws In ActiveWorkbook.Worksheets
Set ws = ws.Cells.Find(What:=SearchString, _
After:=sh.Cells(1, 1), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
End Sub
非常感谢
答案 0 :(得分:0)
如果这对您有用,请告诉我
Sub help()
Dim SearchString As String
Dim cell As Range
Dim ws As Integer
SearchString = "Date :"
For ws = 2 To ActiveWorkbook.Worksheets.Count
UsedRng = Sheets(ws).UsedRange.Address
For Each cell In Range(UsedRng).Cells
If cell.Value = SearchString Then
Sheets(1).Cells(1, ws - 1).Value = cell.Offset(0, 1).Value
Exit For
End If
Next
Next
End Sub