我正在尝试为 Excel 创建一个宏,以从不同的工作表中获取数据并将其放到摘要页面上。因为我不熟悉VBA
我目前的方法是搜索“TOI 分数”(总是在第 45 行找到),将该单元格向右偏移一列,从该单元格复制到.End(xlDown)
该.PasteSpecial
工作transpose = true
表底部的然后搜索下一个实例TOI Score
并重复。最终它将复制的数据复制到摘要页面。
但由于某种原因,我无法让 ExcelTOI Score
在此特定脚本中找到。我知道它可以使用一个简单的宏来找到它,唯一的目的就是找到它,但我不知道是什么把它弄乱了。起初它只是没有找到字符串,但我做了一些事情,现在我得到了运行时错误 91(它说我引用了一个非对象或空对象)。谢谢你提供的所有帮助...
这是我收到错误的脚本:
Sub GrabMyData()
Dim sh As Worksheet
Dim DestSh As Worksheet
Dim CopyRng As Range, CopyHere As Range, CopyHereLastCol As Long, CopyHereLastRow As Long
Dim aCell As Range, bCell As Range, oRange As Range, fullRange As Range
Dim myLastRow As Long, myLastCol As Long
Dim Last As Long
Dim strSearch As String
Dim t As Long
On Error GoTo Err
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Application.DisplayAlerts = False
On Error Resume Next
ActiveWorkbook.Worksheets("Summary Sheet").Delete
On Error GoTo 0
Application.DisplayAlerts = True
Set DestSh = ActiveWorkbook.Worksheets.Add
DestSh.Name = "Summary Sheet"
For Each sh In ActiveWorkbook.Worksheets
If sh.Name <> DestSh.Name Then
strSearch = "TOI Score"
Set oRange = ActiveSheet.Rows(45)
Set aCell = oRange.Find(What:=strSearch, LookIn:=xlValues, _
Lookat:=xlPart, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)