Objective: I have 1 Array of strings, 1 Array of worksheets. Want to count the number of occurrences of each string in each worksheet.
My code:
Option Explicit
Sub Checking()
Dim banks() As String
Dim countrysheets As Variant
Dim sheet As Worksheet
Dim bank As Variant
Dim CountryList, BankList As String
Dim count
Dim bankcount, sheetcount As Integer
CountryList = "CN,AU,India,Thai,TW,INDO-IDR,MY,PHP-LOCAL,SG,SK,NZ"
BankList = "Merrill Lynch,UBS,Citigroup,BNP,Macquarie,Morgan Stanley,Deutsche Bank,HSBC,CLSA,JP Morgan,Credit Suisse, Nomura, Goldman Sachs"
countrysheets = Split(CountryList, ",")
banks = Split(BankList, ",")
sheetcount = 0
For Each sheet In countrysheets
bankcount = 0
For Each bank In banks
count = Application.sheets(sheet).WorksheetFunction.CountIf(sheet.Cells, bank)
ActiveCell.Offset(bankcount, sheetcount).Value = count
bankcount = bankcount + 1
Next
sheetcount = sheetcount + 1
Next
End Sub
Why do I keep getting object required errors?
Thanks!