Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Move Worksheet

3 worksheets. Named A, B, C. Is there a better way to move them then this?

Sub Macro1()
Sheets("A").Select
Sheets("A").Move After:=Sheets(2)
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Move Worksheet

I wouldn't select it first.

TGalin wrote:

3 worksheets. Named A, B, C. Is there a better way to move them then this?

Sub Macro1()
Sheets("A").Select
Sheets("A").Move After:=Sheets(2)
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default Move Worksheet

You don't need to select the sheet. It will be active after the move.

Sub Macro1()
Sheets("A").Move After:=Sheets(2)
End Sub


Other sheet copy/move code:

http://support.microsoft.com/kb/288402

--
Steve

"TGalin" wrote in message
...
3 worksheets. Named A, B, C. Is there a better way to move them then
this?

Sub Macro1()
Sheets("A").Select
Sheets("A").Move After:=Sheets(2)
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Move Worksheet

When I use that formula by itself it works now, however when I add it on to
another macro it doesn't work. Any thoughts?

"Dave Peterson" wrote:

I wouldn't select it first.

TGalin wrote:

3 worksheets. Named A, B, C. Is there a better way to move them then this?

Sub Macro1()
Sheets("A").Select
Sheets("A").Move After:=Sheets(2)
End Sub


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Move Worksheet

Although the formula works by itself when I add it on to another macro
nothing happens. Any thoughts?

"AltaEgo" wrote:

You don't need to select the sheet. It will be active after the move.

Sub Macro1()
Sheets("A").Move After:=Sheets(2)
End Sub


Other sheet copy/move code:

http://support.microsoft.com/kb/288402

--
Steve

"TGalin" wrote in message
...
3 worksheets. Named A, B, C. Is there a better way to move them then
this?

Sub Macro1()
Sheets("A").Select
Sheets("A").Move After:=Sheets(2)
End Sub





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Move Worksheet

Maybe you don't have a sheet named "A" in the activeworkbook???

Maybe the activeworkbook has fewer than 2 sheets???

Or maybe the other code is what's causing the trouble.

TGalin wrote:

When I use that formula by itself it works now, however when I add it on to
another macro it doesn't work. Any thoughts?

"Dave Peterson" wrote:

I wouldn't select it first.

TGalin wrote:

3 worksheets. Named A, B, C. Is there a better way to move them then this?

Sub Macro1()
Sheets("A").Select
Sheets("A").Move After:=Sheets(2)
End Sub


--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default Move Worksheet

Perhaps it lost something in the paste or, as Dave indicates, you need to
the appropriate workbook is active.

I note that you are using a mix of named sheet and sheet index in your code.
Is this what you intend (i.e The sheet named A will appear second in your
tab order after the code runs). Alternatively did you want it to appear
after another specific sheet? The following might help

You can swap two sheets continuously in the same workbook using the same
code if you use the sheet index rather than the sheet name:

Sub Macro1()
Sheets(1).Move After:=Sheets(2)

End Sub

Run the above several times and note the change in location of your first
two sheets in tab order each time.

Now try
Sub Macro1()
Sheets("Sheet1").Move After:=Sheets("Sheet2")

End Sub

After ensuring you have sheets names Sheet1 and Sheet2 in your workbook.




--
Steve

"TGalin" wrote in message
...
Although the formula works by itself when I add it on to another macro
nothing happens. Any thoughts?

"AltaEgo" wrote:

You don't need to select the sheet. It will be active after the move.

Sub Macro1()
Sheets("A").Move After:=Sheets(2)
End Sub


Other sheet copy/move code:

http://support.microsoft.com/kb/288402

--
Steve

"TGalin" wrote in message
...
3 worksheets. Named A, B, C. Is there a better way to move them then
this?

Sub Macro1()
Sheets("A").Select
Sheets("A").Move After:=Sheets(2)
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
Move to a named worksheet from any worksheet in the same workbook tango Excel Programming 2 December 10th 08 12:43 AM
HOW WILL MOVE TO 2ND WORKSHEET [email protected] Excel Worksheet Functions 2 November 22nd 07 08:57 AM
How to move from one Worksheet to another. Don J Excel Discussion (Misc queries) 3 February 20th 07 09:18 PM
Unable to Insert Worksheet/Move and copy worksheet Excel 2003 lukerush Excel Worksheet Functions 2 September 7th 06 05:05 PM
How do I use vb to move from worksheet to worksheet in a workbook. Ed123 Excel Programming 3 March 9th 05 03:59 PM


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