【问题标题】:search "date :" in all sheets except sheet1 then paste the value to sheet1在除 sheet1 之外的所有工作表中搜索“日期:”,然后将值粘贴到 sheet1
【发布时间】:2014-08-05 15:51:24
【问题描述】:

请完成此代码。

我会在所有工作表(工作表 2 到工作表...)中搜索“日期:”一词,如果找到,将值复制到工作表 1

例如:如果在 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

非常感谢

【问题讨论】:

    标签: excel vba


    【解决方案1】:

    让我知道这是否适合你

    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
    

    【讨论】:

      猜你喜欢
      • 2015-06-16
      • 2019-03-09
      • 2016-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-15
      相关资源
      最近更新 更多