#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Copy Sheets

Hi

I have a workbook with an index page with the following
columns

Sheet No Sheet Name Product Copied
1 AU25223 Austravel Y
2 TP52214 Tropical
etc

I have written the following code which copies sheets from
this workbook to other workbooks depending on the value in
column PRODUCT.

This all works fine but at the moment it just works it way
through the list copying the workbooks as it goes. My
problem is that if there are 10 lines with product
Austravel on it - it will open up 10 different copies of
Austravel.xls and then copy the sheet and then close and
then move on to the next one. What I would ideally like is
it to copy all sheets for Austravel in one hit.

Does anyone know how I can do this?

TIA


Sub Copy_Sheets()
Dim shName As String
Dim prName As String
Dim CValue As Range
Dim Cell As Range
Dim owb As Workbook

With Worksheets("Index")
For Each Cell In Range("D3:D9")
If Cell.Value = "" Then
shName = Cell.Offset(0, -2).Text
prName = Cell.Offset(0, -1).Text

Select Case prName
Case "Austravel"
prloc = "S:\Kingston\FA\Overseas Payments\Overseas
Payments Public\Remittance\Long Haul\Austravel\Austravel
Crystal Export File.xls"
fname = "Austravel Crystal Export File.xls"
Case "Tropical"
prloc = "S:\Kingston\FA\Overseas Payments\Overseas
Payments Public\Remittance\Long Haul\Tropical\Tropical
Crystal Export File.xls"
fname = "Tropical Crystal Export File.xls"
Case "Jetsave"
prloc = "S:\Kingston\FA\Overseas Payments\Overseas
Payments Public\Remittance\Long Haul\Jetsave\Jetsave
Crystal Export File.xls"
fname = "Jetsave Crystal Export File.xls"
End Select

With Application
..DisplayAlerts = False
..DisplayAlerts = False
End With

Set owb = Workbooks.Open(prloc)
Workbooks("LH Crystal Export File.xls").Activate
Sheets(shName).Copy Befo=Workbooks(fname).Sheets(1)
Cell.Value = "Y"

With Application
..DisplayAlerts = False
..DisplayAlerts = False
End With

Workbooks(fname).Save
Workbooks(fname).Close

End If
Next Cell
End With

End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy cell info to other sheets, other sheets dont contain all row. Ja Excel Worksheet Functions 1 November 1st 09 12:53 AM
copy sheets kathy Excel Discussion (Misc queries) 3 September 15th 09 03:21 PM
copy sheets Scott Excel Worksheet Functions 4 September 1st 09 07:06 PM
move or copy sheets doesn't copy format ColinX Excel Worksheet Functions 1 May 14th 08 10:07 PM
in VBA Sheets("mysheet").Copy Befo=Sheets(1) how do i get a reference to the newly created copy of this sheet? Daniel Excel Worksheet Functions 1 July 6th 05 09:57 PM


All times are GMT +1. The time now is 07:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"