A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
The code I supplied was not intended to go into a ThisWorkbook sheet, just a standard Module sheet as you've discovered.
When I referred to ThisWorkbook, I was referring to the code that read,
With ThisWorkbook
...
End With
, which might have to be changed to,
With ActiveWorkbook
...
End With
, or...
Set wb = Workbooks.open(<some workbook>)
With wb
...
End with