Can anyone help me figure out why I'm getting an object required error on this code? The line in question is
comnum(a) = comnum(a)+1
I used msgbox to make sure both of these things actually worked, and it spat them out just fine. But for reasons unknown to me, while vba is quite happy to read out both of those individually, setting them equal is a problem?
I cut out a bit of code that doesn't interact with this line in order to save on space, I hope no one minds:
Sub create_sheets(mms, dds, yys, mme, dde, yye)
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim fso As New FileSystemObject
Dim wb1 As Workbook
Dim wb2 As Workbook
Set wb1 = ThisWorkbook
dd = dds
mm = mms
yyyy = yys
'this is where all that unrelated crap went
'it's just formatting, checking if a filepath exists, and if it does_
'opening the file and copying the data.
'It's like 60 unrelated lines, hence my omission
Dim comcol As New Collection
Dim comnum As New Collection
While wb1.Sheets(1).Cells(1, 4) <> "" 'as long as data remains
strnum = 0 'start with no counts of the string
stro = wb1.Sheets(1).Cells(1, 4) 'the string is the contents of the first row's string column
comcol.Add (wb1.Sheets(1).Cells(1, 5))
comnum.Add (0)
For c = 1 To 65536 'for all rows
If wb1.Sheets(1).Cells(c, 4) = stro Then 'if you see the string
strnum = strnum + 1 'count it
For a = 1 To comcol.Count 'go through the entire collection
If comcol(a) = wb1.Sheets(1).Cells(c, 5) Then 'if it finds the string, increments the count of it
MsgBox comnum(a) & " and " & comnum(a) + 1
comnum(a) = comnum(a) + 1
End If
Next a
wb1.Sheets(1).Row(c).Delete
c = c - 1
End If
Next c
Sheets("Results").Activate
Cells(3, 2) = Sheets(1).Cells(1, 4)
While comcol.Count <> 0
Cells(4, 2) = comcol(1) & ", appeared " & comcol(2) & "times"
Wend
Wend
Thanks in advance!