It should either be wb.Worksheets or wb.Sheets, both in the same line will cause an error. Selection, ActiveCell or ActiveSheet should not have anything in front.
In addition to that, the macro recorder does not produce very efficient code, selection and activation are almost never needed, everything in red above can be deleted and the code will still function.
Enhancing that further still, if you have a lot of lines that will refer to wb.WorkSheets(1) then you can use a 'With' block to cut down on the typing / copy & paste needed to write the code.
Note that the lines between With and End With all start with a dot / period, this links them to wb.WorkSheets(1) that the section is working 'With', if there is no dot / period at the start of the line then that line might not be linked to the correct sheet.
One final point. If you have multiple instances of Excel open, then this will not span all of them. Only the workbooks in the instance that holds the code.
Bookmarks