我正在爲一個字符串搜索多個工作表,一旦找到該字符串,它將它複製到MergedData表單中。粘貼單元格值而不是公式
我遇到的問題是應付公式,而不是價值。我一直在尋找幾個小時,似乎無法找到解決方案。
這是我目前使用的代碼。
任何幫助,您可以提供非常感謝!
感謝Aarron
Private Sub CommandButton1_Click()
Dim FirstAddress As String, WhatFor As String
Dim Cell As Range, Sheet As Worksheet
With Application
.ScreenUpdating = False
.EnableEvents = False
.CutCopyMode = False
End With
WhatFor = Sheets("SUB CON PAYMENT FORM").Range("L9")
Worksheets("MergedData").Cells.Clear
If WhatFor = Empty Then Exit Sub
For Each Sheet In Sheets
If Sheet.Name <> "SUB CON PAYMENT FORM" And Sheet.Name <> "MergedData" _
And Sheet.Name <> "Details" Then
With Sheet.Columns(1)
Set Cell = .Find(WhatFor, LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not Cell Is Nothing Then
FirstAddress = Cell.Address
Do
Cell.EntireRow.Copy ActiveWorkbook.Sheets("MergedData").Range("A" & Rows.Count)_
.End(xlUp).Offset(1, 0)
Set Cell = .FindNext(Cell)
Loop Until Cell Is Nothing Or Cell.Address = FirstAddress
End If
End With
End If
Next Sheet
Set Cell = Nothing
End Sub
我可以給你的代碼,但你可能想嘗試錄製宏,做糊特殊值,看看代碼宏吐奶? –
感謝您的幫助,但在其他人的支持下,我已經設法使其工作。 – atame
回答你自己的問題! (你得到一個徽章:)) – moffeltje