View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Petitboeuf
 
Posts: n/a
Default Combining two Subs


Hiya...

Any chance of getting some help regarding the above?

I just want to put a condition for copying each worksheet... I've done
the following but get an error 91 on the save line... :(


Code:
--------------------

Sub Blah()
Dim Counter As Long
Dim Source As Workbook
Dim Destination As Workbook
Dim R As Range


Const MyDir As String = "c:\PromoTrack\MSA\"

Application.ScreenUpdating = False

For Counter = 7800 To 7809
Set Source = Workbooks.Open(MyDir & Counter & ".msa")
Set R = Range("B2")

If R.Value = "Frozen and Chilled" Then

If Counter = 7800 Then
Source.Worksheets.Copy
Set Destination = ActiveWorkbook
ActiveSheet.Name = Counter
Else
Source.Worksheets.Copy After:=Destination.Worksheets(Destination.Workshee ts.Count)
Destination.Worksheets(Destination.Worksheets.Coun t).Name = Counter
End If

End If

Source.Close False

Next

Destination.SaveAs MyDir & "Summary.xls"

Application.ScreenUpdating = True

MsgBox "Frozen MSAs compiled"

End Sub

--------------------


Thanks again in advance!!


--
Petitboeuf
------------------------------------------------------------------------
Petitboeuf's Profile: http://www.excelforum.com/member.php...o&userid=10602
View this thread: http://www.excelforum.com/showthread...hreadid=535960