View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben[_2_] Gord Dibben[_2_] is offline
external usenet poster
 
Posts: 621
Default Copy tab from one spreadsheet to multiple tabs in another spreadsheet while retaining the targets spreadsheets tab names

They cannot all be named Monthly_Totals.

How many of these "excluded" sheets would there be?

Where are they located in the workbook?

There are several methods to exclude those sheets by code.

Below is one method which hides those sheets, appends to visible sheets then
unhides the sheets.

One of the brighter coders will come up with something better..........like not
hiding, I'm sure.

Sub append_data()

Dim ws As Worksheet
Dim rng1 As Range
Dim rng2 As Range
Set rng1 = Sheets("Weekly ACD Report").UsedRange
Workbooks.Open Filename:= _
"C:\ACD\Comp_Acd.xls"
Set myarray = Sheets(Array("Month1", "Month2", "Month3", "Month4"))
myarray.Visible = False
For Each ws In ActiveWorkbook.Worksheets
If ws.Visible = True Then
ws.Activate
Set rng2 = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
rng1.Copy Destination:=rng2
End If
Next ws
For Each ws In myarray
ws.Visible = True
Next ws
With ActiveWorkbook
.Save
.Close
End With

End Sub


Gord


On Wed, 5 Jan 2011 12:47:57 -0800 (PST), Dave wrote:

Thanks for the help. The macro works great. In the C:\ACD\Comp_Acd.xls
file I have tabs that are named Monthly_Totals. I want to exclude them
from this appending process . Can this be done?

Thanks again!!