LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Copy Worksheet, Excel 2000 & 2003

Hello,

The following macro code gives the error: "Subscript out of range" on
this line: "wsA.Copy after:=wbB.Sheets(wbB.Sheets.Count)".

I'm trying to copy certain worksheets form one workbook to another
workbook.

Why am I getting this error and how can the following macro be
modified to copy the worksheets?

Sub CopyWorkSheets_()
Dim wbA As Workbook
Dim wbB As Workbook
Dim wsA As Worksheet
Set wbA = Workbooks("Equip_List_FF.xls")
Set wbB = Workbooks("FF_Zone5_Bldgs.xls")
For Each wsA In wbA.Worksheets
For Each cell In wbB.Worksheets("Index").Range("E4:E27")
If wsA.Visible = xlSheetHidden Then GoTo nws
'MsgBox "Worksheet Name = " & wsA.Name & " " & "Value = " &
Right(wsA.Range("C2").Value, 4) _
& " " & "cell = " & cell
If cell.Text = Right(wsA.Range("C2").Text, 4) Then
wsA.Copy after:=wbB.Sheets(wbB.Sheets.Count)
GoTo nws
End If
Next cell
nws:
Next wsA
End Sub

Than you for your help,
jfcby

 
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
insert rows in locked worksheet - from Excel 2003 to 2000 Venus Excel Discussion (Misc queries) 1 April 1st 09 05:59 PM
Add data to calendar from worksheet, Excel 2000-2003 jfcby[_2_] Excel Programming 0 December 8th 06 07:20 PM
worksheet in excel 2000 different than 2003 StressMonkey Excel Discussion (Misc queries) 2 October 4th 06 02:59 PM
In Excel 2000, Cannot edit cells in worksheet created in 2003? hbca4 Excel Discussion (Misc queries) 2 July 26th 05 06:21 PM
worksheet protection excel 2000 vrs 2003 wtpcomplab Excel Programming 4 June 6th 05 05:37 PM


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

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

About Us

"It's about Microsoft Excel"