P
Petitboeuf
Dear Experts,
I have two separate pieces of code create on two different Sub as pe
below:
Code
-------------------
Sub PromoTrack()
Dim Counter As Long
Dim Source As Workbook
Dim Destination As Workbook
Const MyDir As String = "c:\PromoTrack\MSA\"
Application.ScreenUpdating = False
For Counter = 7800 To 7809
Set Source = Workbooks.Open(MyDir & Counter & ".msa")
If Counter = 7800 Then
Source.Worksheets.Copy
Set Destination = ActiveWorkbook
ActiveSheet.Name = Counter
Else
Source.Worksheets.Copy After:=Destination.Worksheets(Destination.Worksheets.Count)
Destination.Worksheets(Destination.Worksheets.Count).Name = Counter
End If
Source.Close False
Next
Destination.SaveAs MyDir & "Summary.xls"
Application.ScreenUpdating = True
MsgBox "Done"
End Sub
-------------------
Code
-------------------
Sub ReadMSA()
Dim nCol, J, i As Integer
Workbooks.OpenText FileName:="C:\PromoTrack\MSA\7805.MSA"
nCol = 1
With ActiveSheet
For J = 1 To 80
If .Cells(J, nCol).Value = "lblProductCategory" Then
.Cells(J, nCol + 1).Select
.Cells(J, nCol + 1).Copy
Windows("PROMOPLANTRIAL.xls").Activate
Range("B1").Select
ActiveSheet.Paste
Windows("7805.MSA").Activate
End If
Etc… etc…
Next J
End With
End Sub
-------------------
Could you please let me know how to combine the two? I know there wil
be changes in ReadMSA() as I am not using the same variables. Bette
yet, can you help me re-write ReadMSA() so that it is fully integrate
in PromoTrack()?
I only want to copy the workbooks in PromoTrack() based on the conten
of the cell (B2) read via ReadMSA()
Does this makes sense?
Many thanks
I have two separate pieces of code create on two different Sub as pe
below:
Code
-------------------
Sub PromoTrack()
Dim Counter As Long
Dim Source As Workbook
Dim Destination As Workbook
Const MyDir As String = "c:\PromoTrack\MSA\"
Application.ScreenUpdating = False
For Counter = 7800 To 7809
Set Source = Workbooks.Open(MyDir & Counter & ".msa")
If Counter = 7800 Then
Source.Worksheets.Copy
Set Destination = ActiveWorkbook
ActiveSheet.Name = Counter
Else
Source.Worksheets.Copy After:=Destination.Worksheets(Destination.Worksheets.Count)
Destination.Worksheets(Destination.Worksheets.Count).Name = Counter
End If
Source.Close False
Next
Destination.SaveAs MyDir & "Summary.xls"
Application.ScreenUpdating = True
MsgBox "Done"
End Sub
-------------------
Code
-------------------
Sub ReadMSA()
Dim nCol, J, i As Integer
Workbooks.OpenText FileName:="C:\PromoTrack\MSA\7805.MSA"
nCol = 1
With ActiveSheet
For J = 1 To 80
If .Cells(J, nCol).Value = "lblProductCategory" Then
.Cells(J, nCol + 1).Select
.Cells(J, nCol + 1).Copy
Windows("PROMOPLANTRIAL.xls").Activate
Range("B1").Select
ActiveSheet.Paste
Windows("7805.MSA").Activate
End If
Etc… etc…
Next J
End With
End Sub
-------------------
Could you please let me know how to combine the two? I know there wil
be changes in ReadMSA() as I am not using the same variables. Bette
yet, can you help me re-write ReadMSA() so that it is fully integrate
in PromoTrack()?
I only want to copy the workbooks in PromoTrack() based on the conten
of the cell (B2) read via ReadMSA()
Does this makes sense?
Many thanks