Hi all. I've got a VB program that is eporting SQL data to a workbook. It loops to create a new sheet for every employee. It's working well... but I still have some format issues to overcome. I'm ok with VB, but the Excel syntax is all new to me as of this project.
As my code creates a new sheet first before checking for the next employee, it finishes by adding a new sheet to the very end of the workbook. I tried using: ActiveWindow.SelectedSheets.Delete
Unfortunately, the program is jumping back to the first sheet before deleting. This doesn't work well anyway, because finishes the code out by prompting the user is s/he wants to delete before deleting.
Is there a way to search the active workbook and delete any sheets than contain no data?
Thx!
Edit: Argh.. I think I got it. The above statement did work.. it deletes without the prompt when the sheet is empty, I now see. I just had to place it before the code to delete my first 2 blank pages that Excel automatically places in a workbook:
Sub DeleteFirst2Sheets()
Sheets("Sheet2").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Sheet3").Select
ActiveWindow.SelectedSheets.Delete
End Sub
Thx anyway!
Bookmarks