I'm trying to create a macro for Excel to grab data from different worksheets and put it onto a summary page. Because I'm new to VBA
my current method is to search for "TOI Score" (always found in row 45), offset that cell by one column to the right, copy from that cell to .End(xlDown)
and .PasteSpecial
with the transpose = true
at the bottom of that worksheet, then search for the next instance of TOI Score
and repeat. Eventually it will copy the copied data to the summary page.
For some reason though, I cannot get Excel to find TOI Score
within this particular script. I know that it can find it using a bare-bones macro that's only purpose is to find it, but I can't figure out what is messing it up in this one. At first it was simply not finding the string, but I did something and now I'm getting run-time error 91 (the one where it says I'm referencing a non-object or empty object). Thanks for any help you can give...
Here's the script up to where I get the error:
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)