Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Trouble with copy to newly created sheet

Below is my code. I have a worksheet that i want information copied to but i
want to first make a copy of the "template" worksheet then copy the
information and then rehide the "template" worksheet. So i want to copy only
visible cells in the active selection, then copy "SERVICES SUM" and name it
from the inputbox, then paste the visible cells in D22. the copied cells are
no longer copied after i copy the sheet. Any thoughts?


Sub sumsheet()
Dim Rng As Range, Rng1 As Range
Application.ScreenUpdating = False
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets("SERVICES SUM").Visible = True
Sheets("services sum").Select
sheetname = InputBox("Enter desired name for copy of active sheet")
ActiveSheet.Copy After:=ActiveSheet
ActiveSheet.Name = sheetname
Sheets(sheetname).Select
Range("D22").Select
Selection.PasteSpecial Paste:=xlPasteAllExceptBorders, Operation:=xlNone,
_
SkipBlanks:=False, Transpose:=False
Set Rng = Range("d22:n119")
On Error Resume Next
Set Rng1 = Intersect(Rng, _
Columns("e:e").SpecialCells(xlBlanks))
On Error GoTo 0
If Not Rng1 Is Nothing Then Rng1.EntireRow.Delete
Range("a1").Select
Sheets("services sum").Visible = False
Application.ScreenUpdating = True
End Sub

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200705/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Trouble with copy to newly created sheet

Reverse the steps. Copy the sheet 1st, then the cells.

Hth,
Merjet

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Trouble with copy to newly created sheet

I tried that but problem with it is the copied cells will be on a sheet that
i dont know the name of so i cant get back to that sheet and copy the cells
after i have copied the sheet. Ideally i would like to temperarily name the
active sheet, then copy the sum services sheet, go back to the original sheet
copy the cells paste them, and then rename the original sheet to its original
name.

merjet wrote:
Reverse the steps. Copy the sheet 1st, then the cells.

Hth,
Merjet


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200705/1

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Trouble with copy to newly created sheet

I tried that but problem with it is the copied cells will be on
a sheet that i dont know the name of


You can find the name of the sheet with Selection.Worksheet.Name or
Selection.Parent.Name.

Hth,
Merejt

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Trouble with copy to newly created sheet

how would i incorporate this into my code?

merjet wrote:
I tried that but problem with it is the copied cells will be on
a sheet that i dont know the name of


You can find the name of the sheet with Selection.Worksheet.Name or
Selection.Parent.Name.

Hth,
Merejt


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200705/1



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Trouble with copy to newly created sheet

how would i incorporate this into my code?

Dim aName As String
aName = Selection.Worksheet.Name
.. . . .
Sheets(aName).Range(address).Copy

On second thought, there is another way. Declare another range
variable. e.g. rngC, and set it equal to the cells you want to copy
from later.
Set rngC = . . . .
.. . . . . . .
rngC.Copy Destination:= . . . .

Hth,
Merjet

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
Auto Refresh data from original worksheet to newly created copy wolverine Excel Discussion (Misc queries) 0 April 11th 10 04:10 PM
using a cell value to name a newly created workbook Guerilla Excel Discussion (Misc queries) 1 December 18th 06 01:45 AM
cannot copy newly created files to backup, all existing ok NBaum Excel Discussion (Misc queries) 3 July 25th 06 07:29 PM
Can't find newly created userform Benz Excel Programming 1 July 13th 06 05:25 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 04:07 AM.

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"