Le but est de sélectionner, par macro, toutes les
cellules de la plage nommée «tableau»
contenant des nombres pairs.
Peut-on élaguer ?
Sub Sélectionne_Nombres_Pairs()
Dim c As Range
On Error Resume Next
For Each c In Range("tableau")
If IsNumeric(c) Then
If c Mod 2 = 0 Then
i = i + 1
If i = 1 Then
Set ici = c
Else
Set ici = Union(ici, c)
End If
End If
End If
Next
ici.Select
End Sub
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
isabelle
salut Serge,
Peut-on élaguer ?
pas de beaucoup,
Sub Sélectionne_Nombres_Pairs() Dim c As Range On Error Resume Next For Each c In Range("tableau") If IsNumeric(c.Value) Then If c Mod 2 = 0 Then ici = ici & c.Address & "," End If Next Range(Left(ici, Len(ici) - 1)).Select End Sub
isabelle
salut Serge,
Peut-on élaguer ?
pas de beaucoup,
Sub Sélectionne_Nombres_Pairs()
Dim c As Range
On Error Resume Next
For Each c In Range("tableau")
If IsNumeric(c.Value) Then
If c Mod 2 = 0 Then ici = ici & c.Address & ","
End If
Next
Range(Left(ici, Len(ici) - 1)).Select
End Sub
Sub Sélectionne_Nombres_Pairs() Dim c As Range On Error Resume Next For Each c In Range("tableau") If IsNumeric(c.Value) Then If c Mod 2 = 0 Then ici = ici & c.Address & "," End If Next Range(Left(ici, Len(ici) - 1)).Select End Sub
isabelle
garnote
J'ai coupé un autre if :-)
Sub Sélectionne_Nombres_Pairs() Dim c As Range On Error Resume Next For Each c In Range("tableau").SpecialCells(xlCellTypeConstants, 1) If c Mod 2 = 0 Then ici = ici & c.Address & "," Next Range(Left(ici, Len(ici) - 1)).Select End Sub
Serge
"isabelle" a écrit dans le message de news:
salut Serge,
Peut-on élaguer ?
pas de beaucoup,
Sub Sélectionne_Nombres_Pairs() Dim c As Range On Error Resume Next For Each c In Range("tableau") If IsNumeric(c.Value) Then If c Mod 2 = 0 Then ici = ici & c.Address & "," End If Next Range(Left(ici, Len(ici) - 1)).Select End Sub
isabelle
J'ai coupé un autre if :-)
Sub Sélectionne_Nombres_Pairs()
Dim c As Range
On Error Resume Next
For Each c In Range("tableau").SpecialCells(xlCellTypeConstants, 1)
If c Mod 2 = 0 Then ici = ici & c.Address & ","
Next
Range(Left(ici, Len(ici) - 1)).Select
End Sub
Serge
"isabelle" <as.isabellevIE@videotron.ca> a écrit dans le message de news:
40C477D9.F56E613A@videotron.ca...
salut Serge,
Peut-on élaguer ?
pas de beaucoup,
Sub Sélectionne_Nombres_Pairs()
Dim c As Range
On Error Resume Next
For Each c In Range("tableau")
If IsNumeric(c.Value) Then
If c Mod 2 = 0 Then ici = ici & c.Address & ","
End If
Next
Range(Left(ici, Len(ici) - 1)).Select
End Sub
Sub Sélectionne_Nombres_Pairs() Dim c As Range On Error Resume Next For Each c In Range("tableau").SpecialCells(xlCellTypeConstants, 1) If c Mod 2 = 0 Then ici = ici & c.Address & "," Next Range(Left(ici, Len(ici) - 1)).Select End Sub
Serge
"isabelle" a écrit dans le message de news:
salut Serge,
Peut-on élaguer ?
pas de beaucoup,
Sub Sélectionne_Nombres_Pairs() Dim c As Range On Error Resume Next For Each c In Range("tableau") If IsNumeric(c.Value) Then If c Mod 2 = 0 Then ici = ici & c.Address & "," End If Next Range(Left(ici, Len(ici) - 1)).Select End Sub
isabelle
isabelle
très bonne idée ! isabelle
J'ai coupé un autre if :-)
Sub Sélectionne_Nombres_Pairs() Dim c As Range On Error Resume Next For Each c In Range("tableau").SpecialCells(xlCellTypeConstants, 1) If c Mod 2 = 0 Then ici = ici & c.Address & "," Next Range(Left(ici, Len(ici) - 1)).Select End Sub
Serge
"isabelle" a écrit dans le message de news:
salut Serge,
Peut-on élaguer ?
pas de beaucoup,
Sub Sélectionne_Nombres_Pairs() Dim c As Range On Error Resume Next For Each c In Range("tableau") If IsNumeric(c.Value) Then If c Mod 2 = 0 Then ici = ici & c.Address & "," End If Next Range(Left(ici, Len(ici) - 1)).Select End Sub
isabelle
très bonne idée !
isabelle
J'ai coupé un autre if :-)
Sub Sélectionne_Nombres_Pairs()
Dim c As Range
On Error Resume Next
For Each c In Range("tableau").SpecialCells(xlCellTypeConstants, 1)
If c Mod 2 = 0 Then ici = ici & c.Address & ","
Next
Range(Left(ici, Len(ici) - 1)).Select
End Sub
Serge
"isabelle" <as.isabellevIE@videotron.ca> a écrit dans le message de news:
40C477D9.F56E613A@videotron.ca...
salut Serge,
Peut-on élaguer ?
pas de beaucoup,
Sub Sélectionne_Nombres_Pairs()
Dim c As Range
On Error Resume Next
For Each c In Range("tableau")
If IsNumeric(c.Value) Then
If c Mod 2 = 0 Then ici = ici & c.Address & ","
End If
Next
Range(Left(ici, Len(ici) - 1)).Select
End Sub
Sub Sélectionne_Nombres_Pairs() Dim c As Range On Error Resume Next For Each c In Range("tableau").SpecialCells(xlCellTypeConstants, 1) If c Mod 2 = 0 Then ici = ici & c.Address & "," Next Range(Left(ici, Len(ici) - 1)).Select End Sub
Serge
"isabelle" a écrit dans le message de news:
salut Serge,
Peut-on élaguer ?
pas de beaucoup,
Sub Sélectionne_Nombres_Pairs() Dim c As Range On Error Resume Next For Each c In Range("tableau") If IsNumeric(c.Value) Then If c Mod 2 = 0 Then ici = ici & c.Address & "," End If Next Range(Left(ici, Len(ici) - 1)).Select End Sub