View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Combining two different subs w/ similar variables

Hi Matthew

WSNew.delete code you used instead of the Sheet1.delete code I used.


We already set a reference to this sheet so why not use it
And if you run the code in a non english version "Sheet1" is different
WSNew is always working

But there is more, the old code use

WSNew.parent to save and close the file
But if you delete this sheet WSNew = nothing so the code break

After we add the new workbook

Set WSNew = Workbooks.Add(xlWBATWorksheet).Worksheets(1)
Set WBNew = ActiveWorkbook

We set WBNew now so we can use that to save/close the file

WBNew.SaveAs foldername & _
cell.Value & FileExtStr, FileFormatNum


WBNew.Close False


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Matthew Dyer" wrote in message ...
Ron, you are the man! Works just how I wanted it to. I see the
WSNew.delete code you used instead of the Sheet1.delete code I used.
Do you know why it has to be done this way?