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

Help please, I am new to macro and VBA and have a problem,

I neen a macro to run when a worksheet tab is clicked, the macro
peforma a sort on the rest of the tabs the problem is that i need it
to end on that tab and to sort, so when that tab is selected at the
end of the macro the macro runs again and goes into a loop.

Is that a way to run the macro once and stop it?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default Macro Looping Problem

Please post the code you have so far.
--
Charles Chickering

"A good example is twice the value of good advice."


" wrote:

Help please, I am new to macro and VBA and have a problem,

I neen a macro to run when a worksheet tab is clicked, the macro
peforma a sort on the rest of the tabs the problem is that i need it
to end on that tab and to sort, so when that tab is selected at the
end of the macro the macro runs again and goes into a loop.

Is that a way to run the macro once and stop it?

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Macro Looping Problem

Here is one way:

Right click on the sheet tab of the sheet that should sort the sheets.
Select "View Code" and paste in the following two functions:

Private Sub Worksheet_Activate()
Call SheetSortDOSLogic
End Sub

Public Function SheetSortDOSLogic()
Dim lngX As Integer
Dim lngY As Integer
Dim lngSheetCount As Long
lngSheetCount = ActiveWorkbook.Sheets.Count
For lngX = 1 To lngSheetCount
For lngY = lngX + 1 To lngSheetCount
If Sheets(lngX).Name Sheets(lngY).Name Then
Sheets(lngY).Move Befo=Sheets(lngX)
End If
Next lngY
Next lngX
End Function

To make it run again, you must select a different tab and then reselect the
"sort" sheet tab.

HTH

" wrote:

Help please, I am new to macro and VBA and have a problem,

I neen a macro to run when a worksheet tab is clicked, the macro
peforma a sort on the rest of the tabs the problem is that i need it
to end on that tab and to sort, so when that tab is selected at the
end of the macro the macro runs again and goes into a loop.

Is that a way to run the macro once and stop it?

Thanks

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
Looping : For... Next problem LuisE Excel Programming 1 October 4th 07 10:25 PM
Looping Problem ryguy7272 Excel Programming 5 April 5th 07 01:41 AM
Macro looping problem. [email protected] Excel Discussion (Misc queries) 8 October 26th 06 02:44 PM
Looping problem........ Steve Jones Excel Programming 1 September 22nd 06 04:31 PM
Looping Problem Todd Huttenstine[_3_] Excel Programming 5 January 25th 04 12:51 AM


All times are GMT +1. The time now is 06:33 PM.

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"