Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Looping : For... Next problem | Excel Programming | |||
Looping Problem | Excel Programming | |||
Macro looping problem. | Excel Discussion (Misc queries) | |||
Looping problem........ | Excel Programming | |||
Looping Problem | Excel Programming |