Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 44
Default Save row heights with VB copy

I have a scheduling sheet that gets copied at the end of each week and
pasted into a new sheet. (code below). The problem is that I have
several hidden rows that become visible when the sheet is pasted. How
do I copy the original exactly.

Private Sub btnFinal_Click()
Application.ScreenUpdating = False
ActiveSheet.Unprotect
'Finalize Schedule
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = "Week " & Sheets("New Schedule").Range("a2")

Sheets("New Schedule").Select
Cells.Select
Selection.Copy

Dim Shname As String
With Sheets("New Schedule")
Shname = "Week " & Sheets("New Schedule").Range("a2")
End With
On Error Resume Next
Sheets(Shname).Select
On Error GoTo 0




ActiveSheet.Paste
Application.CutCopyMode = False
Range("a:s").Select
ActiveWindow.Zoom

Sheets("New Schedule").Select
Range("Week").Select
Selection.ClearContents
Range("a:s").Select
ActiveWindow.Zoom = True
Range("a2").Select
Range("a2") = Range("a2") + 1
Range("b3") = Range("b3") + 7
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
Application.ScreenUpdating = True

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 367
Default Save row heights with VB copy

On Nov 8, 10:49 am, stewart wrote:
I have a scheduling sheet that gets copied at the end of each week and
pasted into a new sheet. (code below). The problem is that I have
several hidden rows that become visible when the sheet is pasted. How
do I copy the original exactly.

Private Sub btnFinal_Click()
Application.ScreenUpdating = False
ActiveSheet.Unprotect
'Finalize Schedule
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = "Week " & Sheets("New Schedule").Range("a2")

Sheets("New Schedule").Select
Cells.Select
Selection.Copy

Dim Shname As String
With Sheets("New Schedule")
Shname = "Week " & Sheets("New Schedule").Range("a2")
End With
On Error Resume Next
Sheets(Shname).Select
On Error GoTo 0

ActiveSheet.Paste
Application.CutCopyMode = False
Range("a:s").Select
ActiveWindow.Zoom

Sheets("New Schedule").Select
Range("Week").Select
Selection.ClearContents
Range("a:s").Select
ActiveWindow.Zoom = True
Range("a2").Select
Range("a2") = Range("a2") + 1
Range("b3") = Range("b3") + 7
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
Application.ScreenUpdating = True

End Sub


Hi stewart

the problem is, that you are not copying a worksheet...you are adding
a new worksheet and copying the content of the old one into the new
one..

Try this, should work better:

Private Sub btnFinal_Click()
Application.ScreenUpdating = False
ActiveSheet.Unprotect

Dim ws As Worksheet

Worksheets("New Schedule").Copy After:=Sheets(Sheets.Count)
Set ws = Worksheets(Sheets.Count)
ws.Name = "Week " & Sheets("New Schedule").Range("a2")
ws.Select

ws.Range("Week").ClearContents
ws.Range("a2") = ws.Range("a2") + 1
ws.Range("b3") = ws.Range("b3") + 7

ws.Range("a:s").Select
ActiveWindow.Zoom = True

ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True

Application.ScreenUpdating = True

End Sub

hth carlo

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
how to copy row heights from one sheet to another in Excell Hayseed Excel Discussion (Misc queries) 5 April 19th 07 01:34 PM
how to copy row heights from one sheet to another in Excell Hayseed Excel Discussion (Misc queries) 1 January 25th 07 03:27 AM
Excel: copy grid, widths & heights down page: heights wrong! why? K Excel Discussion (Misc queries) 1 June 24th 06 03:06 AM
copy formats column width & row heights between Excel WORKSHEETS? tccc1219 Excel Discussion (Misc queries) 5 November 8th 05 04:22 PM
How to save a file without overwrite or save a copy? SettingChange Setting up and Configuration of Excel 1 November 3rd 05 02:10 AM


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