Hi, I have two arrays based on existing sheets declare in the "sheetsNameGroup" variant and I want to define them in the loop and then activate the sheets outside the loop using (for example) cveSH.Activate, but when I tried it resulted in a 424 "object required" error ", which means I can only call sheets using "sheetsDefGroup(number)". I don't know if it is possible to do it and the closest thing but with the error I mention is the code below
I know I can do a conditional statement if I wanted to Activate the "cve" Sheet through the existing array, but I would like to know if what I tried to do is possible, PD. I'm rlly sorry if my english sintax is not the better at the momment to explain the problem and if i've missed something important
VBA Code:
Sub Test()
Dim cveSH, cweSH, agentsSH, databaseSH As Worksheet 'How I would like to declare my Sheets.
Dim sheetsNameGroup, sheetsDefGroup as Variant 'Existing sheets in my workbook.
Dim counter as Integer
sheetsNameGroup = Array("cve", "cwe", "agents", "database")
sheetsDefGroup = Array("cveSH", "cweSH", "agentsSH", "databaseSH")
For counter = LBound(sheetsNameGroup) To UBound(sheetsNameGroup)
Set sheetsDefGroup(counter) = Worksheets(sheetsNameGroup(counter))
Next counter
End sub