OVH Cloud OVH Cloud

Gros souci de sélection

2 réponses
Avatar
Tatane
Bonjour,

Je voudrais faire une sélection totale sauf la ligne 1 pour définir une
plage. J'ai une partie de ma macro mais il me manque la fonction pour
"soustraire" la ligne 1 à ma sélection.

Voici ce que j'ai écrit:

Sub Trier()

Range("A2:K3").Sort Key1:=Range("A2"), Order1:=xlAscending, Key2:=Range( _
"B2"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal

Dim MASELECTION As Variant
MASELECTION = Range("A2").CurrentRegion.Select
ActiveWorkbook.Names.Add Name:="TRI", RefersToR1C1:=MASELECTION

End Sub

Pour résumer: MASELECTION comprend les lignes 1 à X et il me faudrait 2 à X.

Si quelqu'un peut se pencher sur mon problème ... Merci d'avance.

2 réponses

Avatar
Elliac
Bonjour,
Ajoute après MASELECTION = Range("A2").CurrentRegion.Select :
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1,
Selection.Columns.Count).Select

Camille


Bonjour,

Je voudrais faire une sélection totale sauf la ligne 1 pour définir une
plage. J'ai une partie de ma macro mais il me manque la fonction pour
"soustraire" la ligne 1 à ma sélection.

Voici ce que j'ai écrit:

Sub Trier()

Range("A2:K3").Sort Key1:=Range("A2"), Order1:=xlAscending, Key2:=Range( _
"B2"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:úlse, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal

Dim MASELECTION As Variant
MASELECTION = Range("A2").CurrentRegion.Select
ActiveWorkbook.Names.Add Name:="TRI", RefersToR1C1:=MASELECTION

End Sub

Pour résumer: MASELECTION comprend les lignes 1 à X et il me faudrait 2 à X.

Si quelqu'un peut se pencher sur mon problème ... Merci d'avance.


Avatar
Tatane
Merciiiiiiiiiiiii Camille. C'est parfait pour moi.


Bonjour,
Ajoute après MASELECTION = Range("A2").CurrentRegion.Select :
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1,
Selection.Columns.Count).Select

Camille


Bonjour,

Je voudrais faire une sélection totale sauf la ligne 1 pour définir une
plage. J'ai une partie de ma macro mais il me manque la fonction pour
"soustraire" la ligne 1 à ma sélection.

Voici ce que j'ai écrit:

Sub Trier()

Range("A2:K3").Sort Key1:=Range("A2"), Order1:=xlAscending, Key2:=Range( _
"B2"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:úlse, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal

Dim MASELECTION As Variant
MASELECTION = Range("A2").CurrentRegion.Select
ActiveWorkbook.Names.Add Name:="TRI", RefersToR1C1:=MASELECTION

End Sub

Pour résumer: MASELECTION comprend les lignes 1 à X et il me faudrait 2 à X.

Si quelqu'un peut se pencher sur mon problème ... Merci d'avance.