I've included bits of my code and some debug output.
Whenever I attempt to add a worksheet, either BEFORE or AFTER I get the following ERROR MESSAGE: Method 'Add' of object
if I use the .add without before and after a worksheet is added. The problem is that it is always
added before the active sheet. I need to replace a single sheet in the correct position of possible 10 sheets.
I know the names of the sheets and which one I want to replace, but I can't get EXCEL to move sheets, add sheets by position
Number or name, without getting the ERROR.
Public xlApp As Excel.Application
Public xlBook As Excel.Workbook
Public xlSheet As Excel.Worksheet
Public xlRange As Excel.Range
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
xlBook.Worksheets.Add After:="Accounts Receivable" *****
If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines