我正在尝试开发一个简单的复制+粘贴值,其中宏将占用填充到单元格中的日期,在下一个工作表中搜索日期,并粘贴A2:X2中的值,在那里找到日期。
Sub Copy_PasteVal()
Dim dDate As Range
Dim shtTrack As Worksheet
Dim shtData As Worksheet
Dim c As Range
Dim DestCell As Range
Set shtdata = Sheets(“Daily Total”)
Set shtTrack = Sheets("Overall Daily Tracking")
Set dDate = shtData.Range(“A2”)
Worksheets("shtData").Range("A2:X2").Copy
With Worksheets(shtTrack).Range("a1:a1000")
Set DestCell = .Find(dDate, LookIn:=xlValues)
End With
Worksheets(“shtTrack”).Range(DestCell).PasteSpecial Paste:=xlPasteValues
End Sub
它没有编译,我希望那里的一些大师可以帮助我在VBA中找出编码!
答案 0 :(得分:0)
编辑:我可能会倒退吗?此外,不确定您是否打算清除A列......
Dim dDate
Dim shtTrack As Worksheet
Dim shtData As Worksheet
Dim c As Range
Dim DestCell As Range
Set shtData = Sheets("Daily Total")
Set shtTrack = Sheets("Overall Daily Tracking")
dDate = shtData.Range("A2").Value
Set c = shtData.Range("A2:X2")
With shtTrack.Range("a1:a1000")
Set DestCell = .Find(dDate, LookIn:=xlValues)
If Not DestCell Is Nothing Then
r = DestCell.Row
Else
Exit Sub
End If
End With
With shtTrack
.Range(.Cells(r, 1), .Cells(r, 24)).Value = c.Value
End With