Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Move WorkSheets Within Same WorkBook!!

Hello,

I've created a workbook with 80 worksheets. Now I have added 40 worksheets.
The problem is I need to move the added worksheets but I can't use the work
sheet names to move the worksheets with the following code

Sub ORGANIZE_WORKBOOK_SHEETS()
Sheets("CHICOPEE Q").Select
ActiveWindow.ScrollWorkbookTabs Sheets:=-11
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("CHICOPEE M").Select
Sheets("CHICOPEE M").Move Befo=Sheets(69)
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("HODGES OIL BUILDING M").Select
Sheets("HODGES OIL BUILDING M").Move Befo=Sheets(71)
ActiveWindow.ScrollWorkbookTabs Sheets:=-1
Sheets("HODGES OIL BLDG Q").Select
End Sub

Example:
The order of the work sheets are not alphabetical!
They a Chicopee Q, Chicopee BW, Hodges Oil Building Q, Hodges Oil
Building BW, Visual Art Q, Visual Art BW, Baldwin Hall Q, Baldwin Hall BW,
Main Library Q, Main Library BW

Now when I added my current worksheets they are not in the order I need
them.
They a Chipcopee M, Hodges Oil Building M, Visual Art M, Baldwin Hall M,
Main Library M

The Name of my worksheet is in B2 and B7 and the worksheet tab has the
worksheet name also.

This is what I want to do is move tme Buildings to look like this: Chicopee
Q, Chicopee M, Chicopee BW, Hodges Oil Building Q, Hodges Oil Building M,
Hodges Oil Building BW, Visual Art Q, Visual Art M, Visual Art BW, Baldwin
Hall Q, Baldwin Hall M, Baldwin Hall BW, Main Library Q, Main Library M,
Main Library BW

How can I move the work sheets in a workbook from one location to another
specific location?

Thank you for your help in advance!!!
James Cooper


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Move WorkSheets Within Same WorkBook!!

I would do it like this:
Pull all worksheet names into one worksheet. Let's say on Sheet 1 in
column B.
Sub FindWSNames()
For x = 1 To Sheets.Count
Cells(x, "B") = Sheets(x).Name
Next x
End Sub

Then sort that list anyway you want, and run this code against it.
Sub SortWS()
On Error Resume Next
With Sheets("Sheet1")
For x = 1 To 16 'EDIT TO ACCOUNT FOR YOUR VARIABLES
Sheets(.Cells(x, "B").Text).Move After:=Sheets(Sheets.Count)
Next x
End With

End Sub

Tested it and it works pretty fine.

Regards,
Jamie


James Cooper wrote:
Hello,

I've created a workbook with 80 worksheets. Now I have added 40 worksheets.
The problem is I need to move the added worksheets but I can't use the work
sheet names to move the worksheets with the following code

Sub ORGANIZE_WORKBOOK_SHEETS()
Sheets("CHICOPEE Q").Select
ActiveWindow.ScrollWorkbookTabs Sheets:=-11
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("CHICOPEE M").Select
Sheets("CHICOPEE M").Move Befo=Sheets(69)
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("HODGES OIL BUILDING M").Select
Sheets("HODGES OIL BUILDING M").Move Befo=Sheets(71)
ActiveWindow.ScrollWorkbookTabs Sheets:=-1
Sheets("HODGES OIL BLDG Q").Select
End Sub

Example:
The order of the work sheets are not alphabetical!
They a Chicopee Q, Chicopee BW, Hodges Oil Building Q, Hodges Oil
Building BW, Visual Art Q, Visual Art BW, Baldwin Hall Q, Baldwin Hall BW,
Main Library Q, Main Library BW

Now when I added my current worksheets they are not in the order I need
them.
They a Chipcopee M, Hodges Oil Building M, Visual Art M, Baldwin Hall M,
Main Library M

The Name of my worksheet is in B2 and B7 and the worksheet tab has the
worksheet name also.

This is what I want to do is move tme Buildings to look like this: Chicopee
Q, Chicopee M, Chicopee BW, Hodges Oil Building Q, Hodges Oil Building M,
Hodges Oil Building BW, Visual Art Q, Visual Art M, Visual Art BW, Baldwin
Hall Q, Baldwin Hall M, Baldwin Hall BW, Main Library Q, Main Library M,
Main Library BW

How can I move the work sheets in a workbook from one location to another
specific location?

Thank you for your help in advance!!!
James Cooper


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Move WorkSheets Within Same WorkBook!!

Hello jseven,

Thank you for the code it worked great and will save me a lot of time!

Thank you for your help,
James Cooper

jseven wrote:
I would do it like this:
Pull all worksheet names into one worksheet. Let's say on Sheet 1 in
column B.
Sub FindWSNames()
For x = 1 To Sheets.Count
Cells(x, "B") = Sheets(x).Name
Next x
End Sub

Then sort that list anyway you want, and run this code against it.
Sub SortWS()
On Error Resume Next
With Sheets("Sheet1")
For x = 1 To 16 'EDIT TO ACCOUNT FOR YOUR VARIABLES
Sheets(.Cells(x, "B").Text).Move After:=Sheets(Sheets.Count)
Next x
End With

End Sub

Tested it and it works pretty fine.

Regards,
Jamie


James Cooper wrote:
Hello,

I've created a workbook with 80 worksheets. Now I have added 40 worksheets.
The problem is I need to move the added worksheets but I can't use the work
sheet names to move the worksheets with the following code

Sub ORGANIZE_WORKBOOK_SHEETS()
Sheets("CHICOPEE Q").Select
ActiveWindow.ScrollWorkbookTabs Sheets:=-11
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("CHICOPEE M").Select
Sheets("CHICOPEE M").Move Befo=Sheets(69)
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("HODGES OIL BUILDING M").Select
Sheets("HODGES OIL BUILDING M").Move Befo=Sheets(71)
ActiveWindow.ScrollWorkbookTabs Sheets:=-1
Sheets("HODGES OIL BLDG Q").Select
End Sub

Example:
The order of the work sheets are not alphabetical!
They a Chicopee Q, Chicopee BW, Hodges Oil Building Q, Hodges Oil
Building BW, Visual Art Q, Visual Art BW, Baldwin Hall Q, Baldwin Hall BW,
Main Library Q, Main Library BW

Now when I added my current worksheets they are not in the order I need
them.
They a Chipcopee M, Hodges Oil Building M, Visual Art M, Baldwin Hall M,
Main Library M

The Name of my worksheet is in B2 and B7 and the worksheet tab has the
worksheet name also.

This is what I want to do is move tme Buildings to look like this: Chicopee
Q, Chicopee M, Chicopee BW, Hodges Oil Building Q, Hodges Oil Building M,
Hodges Oil Building BW, Visual Art Q, Visual Art M, Visual Art BW, Baldwin
Hall Q, Baldwin Hall M, Baldwin Hall BW, Main Library Q, Main Library M,
Main Library BW

How can I move the work sheets in a workbook from one location to another
specific location?

Thank you for your help in advance!!!
James Cooper


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Move WorkSheets Within Same WorkBook!!

fantastic

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
Keyboard shortcuts to move between worksheets within a workbook Waj Excel Worksheet Functions 2 March 20th 07 08:24 PM
automatically move cell data in 1 workbook to another workbook Genesis Excel Worksheet Functions 1 November 5th 06 07:35 PM
Move worksheets to a new workbook mrdata[_6_] Excel Programming 9 March 5th 06 09:30 PM
Move between worksheets SM Excel Worksheet Functions 3 October 26th 05 09:10 AM
Worksheets - Add / Move between Mike Excel Programming 1 January 22nd 04 04:17 PM


All times are GMT +1. The time now is 10:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"