I'm setting up a macro to open different websites based on what deal ID cells are not empty in an Excel sheet. It will create four objects and store the objects in a collection. Four is an arbitrary number because I won't ever need more than two, but I created more just in case.
The macro loops through the Excel sheet and picks out as many deal IDs as necessary (deal IDs are appended to the url to go to the different sites).
I get the error saying
Object variable or With block variable not set
on the highlighted line below.
Sub TransactionMatching()
Dim first_day As String
Dim ieapp As Object
Dim ieapp2 As Object
Dim ieapp3 As Object
Dim ieapp4 As Object
' collection to hold deal names
Dim dealnameArray As New Collection
' collection to hold deal IDs
Dim dealIDArray As New Collection
' collection to hold required ieapp objects
Dim totalDealObjectArray As New Collection
' add all ieapp objects to the collection
totalDealObjectArray.Add ieapp
totalDealObjectArray.Add ieapp2
totalDealObjectArray.Add ieapp3
totalDealObjectArray.Add ieapp4
Windows("transaction_matching.xlsm").Activate
' loop through each row in the excel sheet and add the deal names and deal IDs...
' ...with check marks nect to them to their respective collections
For i = 5 To 51
If IsEmpty(Range("C" & i).Value) = False Then
dealnameArray.Add (Range("A" & i).Value)
dealIDArray.Add (Range("B" & i).Value)
End If
Next
'get the required number of objects from the ieapp object collection
For i = 1 To dealnameArray.Count - 1
' set each object in ieapp object collection to a new internet explorer object
Set totalDealObjectArray(i) = New InternetExplorerMedium
totalDealObjectArray(i).Visible = True
' define the last business day
lastDay = DateSerial(Year(Date), Month(Date), 0)
' define the first day of the previous month
first_day = lastDay - Day(lastDay) + 1
With totalDealObjectArray(i)
.navigate "http://website" & dealIDArray(i)
Application.DisplayFullScreen = True
Call busy((totalDealObjectArray(i)))
Call DoThings((totalDealObjectArray(i)))
End With
Next
Application.WindowState = xlNormal
Application.WindowState = xlMaximized
End Sub

