Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Adding a worksheet within the workbook at specific position

hi Guys,
Need Help. I am writing a macro to add a worksheet within a workbook and
named it "DrListWorkCopy". I then copy a range of cells from Worksheet
"DrList" into it.

How do I dictate that "DrListWorkCopy" is incerted right after worksheet
"Targets" within the workbook?

I tried:
Set NewWks = Worksheets.Add After:=sheets("Targets")

but got a syntax error.

Here is how I coded the whole procedu

Sub DuplicateDrList()

Dim NewWks As Worksheet
Dim SourceWks As Worksheet

Set SourceWks = Sheets("DrList")
Set NewWks = Worksheets.Add
NewWks.Name = "DrListWorkCopy"
With SourceWks
.Range("A15:AJ" & SourceWks.Range("AJ65536").End(xlUp).Row).Copy
Sheets("DrListWorkCopy").Paste
End With
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Adding a worksheet within the workbook at specific position

Hi

This should do it:

Set NewWks = Worksheets.Add(after:=Sheets("Target"))

Regards,
Per

On 29 Okt., 05:15, Blubber wrote:
hi Guys,
Need Help. I am writing a macro to add a worksheet within a workbook and
named it "DrListWorkCopy". I then copy a range of cells from Worksheet
"DrList" into it.

How do I dictate that "DrListWorkCopy" is incerted right after worksheet
"Targets" within the workbook?

I tried:
Set NewWks = Worksheets.Add *After:=sheets("Targets")

but got a syntax error.

Here is how I coded the whole procedu

Sub DuplicateDrList()

*Dim NewWks As Worksheet
*Dim SourceWks As Worksheet

Set SourceWks = Sheets("DrList")
Set NewWks = Worksheets.Add
NewWks.Name = "DrListWorkCopy"
*With SourceWks
*.Range("A15:AJ" & SourceWks.Range("AJ65536").End(xlUp).Row).Copy
* Sheets("DrListWorkCopy").Paste
End With
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Adding a worksheet within the workbook at specific position

Hey Thanks Per Jessen. It worked perfectly.

"Per Jessen" wrote:

Hi

This should do it:

Set NewWks = Worksheets.Add(after:=Sheets("Target"))

Regards,
Per

On 29 Okt., 05:15, Blubber wrote:
hi Guys,
Need Help. I am writing a macro to add a worksheet within a workbook and
named it "DrListWorkCopy". I then copy a range of cells from Worksheet
"DrList" into it.

How do I dictate that "DrListWorkCopy" is incerted right after worksheet
"Targets" within the workbook?

I tried:
Set NewWks = Worksheets.Add After:=sheets("Targets")

but got a syntax error.

Here is how I coded the whole procedu

Sub DuplicateDrList()

Dim NewWks As Worksheet
Dim SourceWks As Worksheet

Set SourceWks = Sheets("DrList")
Set NewWks = Worksheets.Add
NewWks.Name = "DrListWorkCopy"
With SourceWks
.Range("A15:AJ" & SourceWks.Range("AJ65536").End(xlUp).Row).Copy
Sheets("DrListWorkCopy").Paste
End With
End Sub



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
Open workbook to specific worksheet mathel Excel Programming 4 February 1st 10 06:46 PM
Open Workbook to Specific Worksheet? Steven Hilgendorf Excel Discussion (Misc queries) 14 June 27th 07 12:22 AM
How to open a workbook on a specific worksheet. kevincanuk Excel Worksheet Functions 2 September 26th 06 02:21 PM
Copy Data from Workbook into specific Worksheet in other Workbook? kingdt Excel Discussion (Misc queries) 1 March 16th 06 06:55 PM
Open a specific worksheet in workbook leem Excel Programming 2 June 9th 05 04:59 PM


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