PC Review


Reply
Thread Tools Rate Thread

Adding a worksheet within the workbook at specific position

 
 
Blubber
Guest
Posts: n/a
 
      29th Oct 2008
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 procedure:

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 With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      29th Oct 2008
Hi

This should do it:

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

Regards,
Per

On 29 Okt., 05:15, Blubber <Blub...@discussions.microsoft.com> 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 procedure:
>
> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to move worksheet into specific position? Eric Microsoft Excel Programming 3 1st Jun 2010 02:04 PM
Open workbook to specific worksheet =?Utf-8?B?bWF0aGVs?= Microsoft Excel Programming 4 1st Feb 2010 06:46 PM
Copy Data from Workbook into specific Worksheet in other Workbook? kingdt Microsoft Excel Misc 1 16th Mar 2006 06:55 PM
open to a specific worksheet in a workbook dismas Microsoft Excel Misc 2 25th Jun 2004 12:26 AM
Re: Importing into a specific worksheet of a workbook. DDM Microsoft Excel Misc 1 13th May 2004 04:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:01 AM.