Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22
Default Macro to group sheet by certain letters at the end

Hi:

I'd like you to help me with grouping worksheets. if the sheets contain
letter of "IS" at the end of the tab name, group them together.

For example, abc_IS, test1_IS, test2-IS.

So, If the sheets contain IS at the end of the tab name, group them
together, and move them first. Thanks for your help!


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default Macro to group sheet by certain letters at the end

Use the macro
Sub movesheets()
For Each ws In Worksheets
If (Right(ws.Name, 2) = "IS") Then
ws.Move _
befo=Worksheets(1)
End If
Next

If case is not important then change ws.Name to UCase(ws.name) in the macro

"bioyyy" wrote:

Hi:

I'd like you to help me with grouping worksheets. if the sheets contain
letter of "IS" at the end of the tab name, group them together.

For example, abc_IS, test1_IS, test2-IS.

So, If the sheets contain IS at the end of the tab name, group them
together, and move them first. Thanks for your help!


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22
Default Macro to group sheet by certain letters at the end

Sheeloo:

Thanks for your help. It works great.



"Sheeloo" wrote:

Use the macro
Sub movesheets()
For Each ws In Worksheets
If (Right(ws.Name, 2) = "IS") Then
ws.Move _
befo=Worksheets(1)
End If
Next

If case is not important then change ws.Name to UCase(ws.name) in the macro

"bioyyy" wrote:

Hi:

I'd like you to help me with grouping worksheets. if the sheets contain
letter of "IS" at the end of the tab name, group them together.

For example, abc_IS, test1_IS, test2-IS.

So, If the sheets contain IS at the end of the tab name, group them
together, and move them first. Thanks for your help!


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22
Default Macro to group sheet by certain letters at the end

Sheeloo,

I have a questions. It works fine if I put it in the module 1. However, when
I put it in the macro toolbar, I got an error in this line:

For Each ws in Worksheets (it highlight ws in blue color).

Any suggestions. Thanks,


"Sheeloo" wrote:

Use the macro
Sub movesheets()
For Each ws In Worksheets
If (Right(ws.Name, 2) = "IS") Then
ws.Move _
befo=Worksheets(1)
End If
Next

If case is not important then change ws.Name to UCase(ws.name) in the macro

"bioyyy" wrote:

Hi:

I'd like you to help me with grouping worksheets. if the sheets contain
letter of "IS" at the end of the tab name, group them together.

For example, abc_IS, test1_IS, test2-IS.

So, If the sheets contain IS at the end of the tab name, group them
together, and move them first. Thanks for your help!


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22
Default Macro to group sheet by certain letters at the end

Sheelo:

I forgot, the error is WS (variable is not defined). Thanks

"Sheeloo" wrote:

Use the macro
Sub movesheets()
For Each ws In Worksheets
If (Right(ws.Name, 2) = "IS") Then
ws.Move _
befo=Worksheets(1)
End If
Next

If case is not important then change ws.Name to UCase(ws.name) in the macro

"bioyyy" wrote:

Hi:

I'd like you to help me with grouping worksheets. if the sheets contain
letter of "IS" at the end of the tab name, group them together.

For example, abc_IS, test1_IS, test2-IS.

So, If the sheets contain IS at the end of the tab name, group them
together, and move them first. Thanks for your help!




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default Macro to group sheet by certain letters at the end

replace
For Each ws In Worksheets
with
For Each ws In ActiveWorkbook.Worksheets

and
befo=Worksheets(1)
with
befo=ActiveWorkbook.Worksheets(1)

I have not tested it but this should work. You basically need to pass the
activeworkbook when invoking from toolbar...


"bioyyy" wrote:

Sheelo:

I forgot, the error is WS (variable is not defined). Thanks

"Sheeloo" wrote:

Use the macro
Sub movesheets()
For Each ws In Worksheets
If (Right(ws.Name, 2) = "IS") Then
ws.Move _
befo=Worksheets(1)
End If
Next

If case is not important then change ws.Name to UCase(ws.name) in the macro

"bioyyy" wrote:

Hi:

I'd like you to help me with grouping worksheets. if the sheets contain
letter of "IS" at the end of the tab name, group them together.

For example, abc_IS, test1_IS, test2-IS.

So, If the sheets contain IS at the end of the tab name, group them
together, and move them first. Thanks for your help!


  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22
Default Macro to group sheet by certain letters at the end

Sheelo:

I try but still got an compile error: variable not defined for ws. Thanks,

"Sheeloo" wrote:

replace
For Each ws In Worksheets
with
For Each ws In ActiveWorkbook.Worksheets

and
befo=Worksheets(1)
with
befo=ActiveWorkbook.Worksheets(1)

I have not tested it but this should work. You basically need to pass the
activeworkbook when invoking from toolbar...


"bioyyy" wrote:

Sheelo:

I forgot, the error is WS (variable is not defined). Thanks

"Sheeloo" wrote:

Use the macro
Sub movesheets()
For Each ws In Worksheets
If (Right(ws.Name, 2) = "IS") Then
ws.Move _
befo=Worksheets(1)
End If
Next

If case is not important then change ws.Name to UCase(ws.name) in the macro

"bioyyy" wrote:

Hi:

I'd like you to help me with grouping worksheets. if the sheets contain
letter of "IS" at the end of the tab name, group them together.

For example, abc_IS, test1_IS, test2-IS.

So, If the sheets contain IS at the end of the tab name, group them
together, and move them first. Thanks for your help!


  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default Macro to group sheet by certain letters at the end

How are you assigning to the macro toolbar?
I put it in my personal.xls and attached the macro to a button. It worked
fine without any modification.
Do you have option Explicit set?

Try the following;

Sub movesheets()
'added declaration
Dim ws As Worksheet
For Each ws In Worksheets
If (Right(ws.Name, 2) = "IS") Then
ws.Move _
befo=Worksheets(1)
End If
Next
End Sub


"bioyyy" wrote:

Sheelo:

I fix, I just added this line:

Dim ws As Worksheet

BTW, thanks for all your help.



"Sheeloo" wrote:

replace
For Each ws In Worksheets
with
For Each ws In ActiveWorkbook.Worksheets

and
befo=Worksheets(1)
with
befo=ActiveWorkbook.Worksheets(1)

I have not tested it but this should work. You basically need to pass the
activeworkbook when invoking from toolbar...


"bioyyy" wrote:

Sheelo:

I forgot, the error is WS (variable is not defined). Thanks

"Sheeloo" wrote:

Use the macro
Sub movesheets()
For Each ws In Worksheets
If (Right(ws.Name, 2) = "IS") Then
ws.Move _
befo=Worksheets(1)
End If
Next

If case is not important then change ws.Name to UCase(ws.name) in the macro

"bioyyy" wrote:

Hi:

I'd like you to help me with grouping worksheets. if the sheets contain
letter of "IS" at the end of the tab name, group them together.

For example, abc_IS, test1_IS, test2-IS.

So, If the sheets contain IS at the end of the tab name, group them
together, and move them first. Thanks for your help!


  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22
Default Macro to group sheet by certain letters at the end

Sheelo:

I fix, I just added this line:

Dim ws As Worksheet

BTW, thanks for all your help.



"Sheeloo" wrote:

replace
For Each ws In Worksheets
with
For Each ws In ActiveWorkbook.Worksheets

and
befo=Worksheets(1)
with
befo=ActiveWorkbook.Worksheets(1)

I have not tested it but this should work. You basically need to pass the
activeworkbook when invoking from toolbar...


"bioyyy" wrote:

Sheelo:

I forgot, the error is WS (variable is not defined). Thanks

"Sheeloo" wrote:

Use the macro
Sub movesheets()
For Each ws In Worksheets
If (Right(ws.Name, 2) = "IS") Then
ws.Move _
befo=Worksheets(1)
End If
Next

If case is not important then change ws.Name to UCase(ws.name) in the macro

"bioyyy" wrote:

Hi:

I'd like you to help me with grouping worksheets. if the sheets contain
letter of "IS" at the end of the tab name, group them together.

For example, abc_IS, test1_IS, test2-IS.

So, If the sheets contain IS at the end of the tab name, group them
together, and move them first. Thanks for your help!


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
list sheet 1 - same cell (eg A1) in a group of worksheets sheet Helen B Excel Worksheet Functions 2 February 10th 08 12:51 AM
How can I convert a group of numbers to a group of letters? CarlG Excel Worksheet Functions 9 August 18th 06 03:31 PM
Deleting a space between a group of Numbers & Letters in a cell Melissa New Users to Excel 6 May 1st 06 01:35 PM
How do I group worksheets (Lotus 123 function is "Sheet>Group Shee jaking Excel Worksheet Functions 2 August 30th 05 02:09 PM
Using a macro how do I group every sheet within a book? Pank Mehta Excel Discussion (Misc queries) 3 March 17th 05 06:44 PM


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