G
Gareth
I am using the code below (which I got from this NG) in a macro that copies
6 sheets from file A into a new file.
The sheet code is not required in the new file so is deleted using the
following:
Dim VBComp As VBIDE.VBComponent, Wb As Excel.Workbook
Set Wb = ActiveWorkbook
For Each VBComp In Wb.VBProject.VBComponents
Select Case VBComp.Type
Case vbext_ct_Document
With VBComp.CodeModule
..DeleteLines StartLine:=1, Count:=.CountOfLines
End With
Case Else
Wb.VBProject.VBComponents.Remove VBComp
End Select
Next VBComp
I now find that I need to keep the code in 2 sheets that are copied - sheet1
and sheet2.
Could someone suggest how to alter the code in order to achieve this?
Thanks in advance
Gareth
6 sheets from file A into a new file.
The sheet code is not required in the new file so is deleted using the
following:
Dim VBComp As VBIDE.VBComponent, Wb As Excel.Workbook
Set Wb = ActiveWorkbook
For Each VBComp In Wb.VBProject.VBComponents
Select Case VBComp.Type
Case vbext_ct_Document
With VBComp.CodeModule
..DeleteLines StartLine:=1, Count:=.CountOfLines
End With
Case Else
Wb.VBProject.VBComponents.Remove VBComp
End Select
Next VBComp
I now find that I need to keep the code in 2 sheets that are copied - sheet1
and sheet2.
Could someone suggest how to alter the code in order to achieve this?
Thanks in advance
Gareth