Here is the associated code: It says the error is in the definition of the function operation() I feel like I need to include something, but I am not sure what. Can anybody please advise on what I need to do? I know to go to Tools > References > .. but after that I am not sure.
Sub operation()
'
' Macro5 Macro
'
'
Dim Erw, firstRow, lastRow
firstRow = 1
Last Row = Range("B" & Rows.Count).End(xlUp).Row
For Erw = firstRow To lastRow
Dim newRow
newRow = firstRow + 4
Range("B" & newRow).Select
ActiveCell.FormulaR1C1 = Range("B" & newRow)
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;ActiveCell.FormulaR1C1", _
Destination:=Range("$D$5"))
.Name = "collections1504_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
nextRow = nextRow + 1
Next Erw
Range("D3").Select
Selection.Copy
Range("C5").Select
Selection.PasteSpecial Paste:=xlPasteValues, operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("D5:P143").Select
Application.CutCopyMode = False
Selection.QueryTable.Delete
Selection.ClearContents
End Sub
Option Explicitat the top of your code, it will automatically highlight and capitalize your variable names for you as you type. Anything that doesn't highlight/capitalize properly is a typo. Very handy tool for finding these errors. (for example, I'dDim LastRow as Integer, then typinglastrowwould get changed toLastRow, so I know it's right. If I'd typedlast rowit wouldn't get capitalized correctly, so I'd know something was wrong)