selection lignes groupees

M

Marc

Guest
Existe-il un code pour selectionner automatiquement des lignes groupees (peu importe le nombre de lignes dans le groupe)
 
S

STéphane

Guest
Bonjour

ce code a besoin d'être travaillé.
pour voir comment il réagit, créerun groupe mais ne vous positionner pas sur la ligne d'en-tête si ce n'est sur la première ligne suivante du groupe.


Sub Groupe_demo1()
Dim TgtRow As Integer, ReadRow As Integer, rg_TgtRow As Range, rg_TgtRange As Range

TgtRow = Selection.Row
Set rg_TgtRow = ActiveSheet.Rows(TgtRow): lvl = rg_TgtRow.OutlineLevel
Set rg_TgtRange = rg_TgtRow
ReadRow = TgtRow + 1
Do Until ActiveSheet.Rows(ReadRow).OutlineLevel <> lvl
If ActiveSheet.Rows(ReadRow).OutlineLevel = lvl Then Set rg_TgtRange = Union(rg_TgtRange, ActiveSheet.Rows(ReadRow))
ReadRow = ReadRow + 1
Loop
rg_TgtRange.Select
End Sub

peut-être suffit-il juste de contrôler que les lignes suivantes soit d'un niveau inférieur de 1 à la ligne d'en-tête.

c'est déjà un truc à te mettre sous la dent depuis le temps que tu attends

bye
Stéphane

ps : d'autres bouts de code que je pensais avoir mis sur le forum concernant les groupes :


'http://groups.google.fr/groups?hl=fr&lr=&ie=UTF-8&threadm=36f83011.575294075%40news.eclipse.net&rnum=4&prev=/groups%3Fhl%3Dfr%26lr%3D%26ie%3DISO-8859-1%26q%3Dexcel%2Bdetect%2Boutline%26btnG%3DRecherche%2BGoogle%26meta%3Dgroup%253Dmicrosoft.public.excel.programming
'Message 3 in thread
'De :Bob Flisser (bob@nospam.swschool.com)
'Objet: Re: Still can 't read Outline levels
'Groupes de discussion :microsoft.public.excel.programming
'View this article only
'Date :1999/03/23
'
'
'Thanks for your response. Your method will set the outline level for a
'given row, if you want to control its relationship to an outline. But
'after a lot of searching, I *finally* figured out 95% of toggling
'outlines between collapsed and open:
'
Sub dddd()
Dim oLevel As Boolean
oLevel = Rows(13).ShowDetail
Rows(13).ShowDetail = Not oLevel
End Sub

'
'Note that you have to know the summary row is #13. If you want to
'collapse or hide the outline based on what cell is selected (if you
'don 't know the row number), this will toggle successfully:
Sub dhdh()
Dim oLevel As Boolean
Set myRange = ActiveCell.CurrentRegion
lastRow = myRange.Rows.Count
oLevel = myRange.Rows(lastRow).ShowDetail
myRange.Rows(lastRow).ShowDetail = Not oLevel
End Sub
 

Discussions similaires

Réponses
3
Affichages
230

Statistiques des forums

Discussions
312 192
Messages
2 086 054
Membres
103 110
dernier inscrit
Privé