Isaac
Lifelong Learner
- Local time
- Today, 09:12
- Joined
- Mar 14, 2017
- Messages
- 11,055
I recently wrote a function to determine whether 2 Excel workbooks were the same - Sheet count, Sheet names, Header values of all sheets. (True/false).
Over the past 24 hours, I've probably spent 3-4 hours troubleshooting why it was returning "False" when I KNEW the files were the same - I created one as a copy!
Having gotten to where I usually write code correctly the first time, I was so perplexed. I sat in debug mode, staring at a Set statement failing to Set -
For Each wsOld in wbOld.Worksheets
Set wsNew = wbNew.Worksheets(wsOld.Name)
...
Next wsOld
etc.
My most recent hunch was there was something about wsOld.Name that wasn't appropriate for a Worksheets() index reference - even though MS clearly states Worksheet.Name returns a String Value, so it must be OK.
Literally 3 hours........Until I realized something extraordinary. Worksheet is not spelled Worksheeet
Who knew !?
Over the past 24 hours, I've probably spent 3-4 hours troubleshooting why it was returning "False" when I KNEW the files were the same - I created one as a copy!
Having gotten to where I usually write code correctly the first time, I was so perplexed. I sat in debug mode, staring at a Set statement failing to Set -
For Each wsOld in wbOld.Worksheets
Set wsNew = wbNew.Worksheets(wsOld.Name)
...
Next wsOld
etc.
My most recent hunch was there was something about wsOld.Name that wasn't appropriate for a Worksheets() index reference - even though MS clearly states Worksheet.Name returns a String Value, so it must be OK.
Literally 3 hours........Until I realized something extraordinary. Worksheet is not spelled Worksheeet
Who knew !?
