Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
bob bob is offline
external usenet poster
 
Posts: 16
Default copy to hidden sheet

the following code will copy the source to data sheet if it is the first
postition on destination but i get an error if i hide the temporary data
sheet
how do i copy to a hidden sheet

ActiveWorkbook.Windows(1).Caption = "Book1"

'delete data sheet each time before copy
Application.DisplayAlerts = False 'trun off del warning
Windows("test1.xls").Activate
Sheets("Data").Select

ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True 'trun warning back on
Windows("Book1").Activate

' COPY to test1 workbook & Data sheet, place at beginning
ActiveWorkbook.ActiveSheet.Copy Befo=Workbooks("test1.xls").Sheets(1)
' Rename first sheet
Workbooks("test1.xls").Sheets(1).Name = "Data"





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default copy to hidden sheet

Bob,

I don't see too much copying going on in your code, just a sheet delete.

The problem is trying to select a hidden sheet, as select is giving it
focus, which doesn't add up if it's hidden. You can do it without selecting
by changing these lines

Sheets("Data").Select
ActiveWindow.SelectedSheets.Delete

to

Worksheets("Data").Delete


So where does copy come into it?

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"bob" wrote in message
. ca...
the following code will copy the source to data sheet if it is the first
postition on destination but i get an error if i hide the temporary data
sheet
how do i copy to a hidden sheet

ActiveWorkbook.Windows(1).Caption = "Book1"

'delete data sheet each time before copy
Application.DisplayAlerts = False 'trun off del warning
Windows("test1.xls").Activate
Sheets("Data").Select

ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True 'trun warning back on
Windows("Book1").Activate

' COPY to test1 workbook & Data sheet, place at beginning
ActiveWorkbook.ActiveSheet.Copy Befo=Workbooks("test1.xls").Sheets(1)
' Rename first sheet
Workbooks("test1.xls").Sheets(1).Name = "Data"







  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default copy to hidden sheet

The sheet to be copied is always assumed to be the activesheet in Book1 in
your code. You give no other information about it. The solution would be
to refer to it specifically without assuming it is the activesheet - but you
don't provide enough information to give an example.

Regards,
Tom Ogilvy

bob wrote in message
. ca...
the following code will copy the source to data sheet if it is the first
postition on destination but i get an error if i hide the temporary data
sheet
how do i copy to a hidden sheet

ActiveWorkbook.Windows(1).Caption = "Book1"

'delete data sheet each time before copy
Application.DisplayAlerts = False 'trun off del warning
Windows("test1.xls").Activate
Sheets("Data").Select

ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True 'trun warning back on
Windows("Book1").Activate

' COPY to test1 workbook & Data sheet, place at beginning
ActiveWorkbook.ActiveSheet.Copy Befo=Workbooks("test1.xls").Sheets(1)
' Rename first sheet
Workbooks("test1.xls").Sheets(1).Name = "Data"







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 hidden sheet data Atiq Excel Discussion (Misc queries) 2 January 27th 10 08:41 PM
after creating a copy of a sheet, several rows missing (not hidden dcdus Excel Discussion (Misc queries) 11 September 15th 09 10:13 PM
Copy and Paste with hidden columns remaining hidden Pendelfin Excel Discussion (Misc queries) 2 February 26th 09 11:35 AM
Excel: copy and paste only shown not hidden cells into new sheet MU Excel Discussion (Misc queries) 1 February 6th 06 10:31 PM
How Can I copy a sheet that has hidden rows without copying the h. ibrahim Excel Worksheet Functions 1 January 13th 05 01:25 AM


All times are GMT +1. The time now is 07:55 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"