Bjr =E0 tous !
Petit probl=E8me :
Je selectionne une colonne avec une macro.
Je souhaiterais que ma boucle s'arrete une fois la=20
derniere cellule rencontr=E9e
qui peut etre vide ou non...
Car l=E0 elle tend vers l'infinie...
Avez vous une id=E9e ?
Ne serait ce pas :
range("A65536").end(xlup) ?
Voici mon code :
Range("R1").Select
=20
For Each cell In Range(ActiveCell, ActiveCell
(1, 2).End(xlDown)(1, 0))
' --- si la cellule est vide
If IsEmpty(cell) =3D True Then
cell.Select
cell.Interior.ColorIndex =3D 8
End If
=20
Next cell
Nosferlato
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
Daniel.M
Bonjour,
Enlève le Cell.Select. De toute façon, tu n'en as pas besoin.
Salutations,
Daniel M.
"Nosferalto" wrote in message news:103a01c38367$2b2f34d0$ Bjr à tous ! Petit problème : Je selectionne une colonne avec une macro. Je souhaiterais que ma boucle s'arrete une fois la derniere cellule rencontrée qui peut etre vide ou non... Car là elle tend vers l'infinie... Avez vous une idée ?
Ne serait ce pas : range("A65536").end(xlup) ?
Voici mon code :
Range("R1").Select
For Each cell In Range(ActiveCell, ActiveCell (1, 2).End(xlDown)(1, 0)) ' --- si la cellule est vide If IsEmpty(cell) = True Then cell.Select cell.Interior.ColorIndex = 8 End If
Next cell Nosferlato
Bonjour,
Enlève le Cell.Select. De toute façon, tu n'en as pas besoin.
Salutations,
Daniel M.
"Nosferalto" <nosferalto@yahoo.fr> wrote in message
news:103a01c38367$2b2f34d0$a001280a@phx.gbl...
Bjr à tous !
Petit problème :
Je selectionne une colonne avec une macro.
Je souhaiterais que ma boucle s'arrete une fois la
derniere cellule rencontrée
qui peut etre vide ou non...
Car là elle tend vers l'infinie...
Avez vous une idée ?
Ne serait ce pas :
range("A65536").end(xlup) ?
Voici mon code :
Range("R1").Select
For Each cell In Range(ActiveCell, ActiveCell
(1, 2).End(xlDown)(1, 0))
' --- si la cellule est vide
If IsEmpty(cell) = True Then
cell.Select
cell.Interior.ColorIndex = 8
End If
Enlève le Cell.Select. De toute façon, tu n'en as pas besoin.
Salutations,
Daniel M.
"Nosferalto" wrote in message news:103a01c38367$2b2f34d0$ Bjr à tous ! Petit problème : Je selectionne une colonne avec une macro. Je souhaiterais que ma boucle s'arrete une fois la derniere cellule rencontrée qui peut etre vide ou non... Car là elle tend vers l'infinie... Avez vous une idée ?
Ne serait ce pas : range("A65536").end(xlup) ?
Voici mon code :
Range("R1").Select
For Each cell In Range(ActiveCell, ActiveCell (1, 2).End(xlDown)(1, 0)) ' --- si la cellule est vide If IsEmpty(cell) = True Then cell.Select cell.Interior.ColorIndex = 8 End If
Next cell Nosferlato
Pierre Fauconnier
Bonjour
1. Tu n'as pas besoin de sélectionner une cellule pour travailler dessus. 2. Je ne comprends par bien la complication de ta boucle for each ...
Ceci pourrait-il te convenir ?
Sub Test() Dim Cellule As Range
For Each Cellule In Range(Range("r1"), Range("r65536").End(xlUp)) If IsEmpty(Cellule) = True Then Cellule.Interior.ColorIndex = 8 End If Next Cellule End Sub
-- Cela convient-il? ---- Pierre Fauconnier "C'est lorsqu'il y a un temps mort qu'il faut tuer le temps..." (remplacer NOSPAM par pfi pour me répondre. Merci)
nosferalto wrote:
Merci, Mais ma boucle reste tout le temps inifie... meme en enlevant le cell... @ suivre... Nosferlato
-----Message d'origine----- Bonjour,
Enlève le Cell.Select. De toute façon, tu n'en as pas besoin.
Salutations,
Daniel M.
"Nosferalto" wrote in message news:103a01c38367$2b2f34d0$ Bjr à tous ! Petit problème : Je selectionne une colonne avec une macro. Je souhaiterais que ma boucle s'arrete une fois la derniere cellule rencontrée qui peut etre vide ou non... Car là elle tend vers l'infinie... Avez vous une idée ?
Ne serait ce pas : range("A65536").end(xlup) ?
Voici mon code :
Range("R1").Select
For Each cell In Range(ActiveCell, ActiveCell (1, 2).End(xlDown)(1, 0)) ' --- si la cellule est vide If IsEmpty(cell) = True Then cell.Select cell.Interior.ColorIndex = 8 End If
Next cell Nosferlato
.
Bonjour
1. Tu n'as pas besoin de sélectionner une cellule pour travailler dessus.
2. Je ne comprends par bien la complication de ta boucle for each ...
Ceci pourrait-il te convenir ?
Sub Test()
Dim Cellule As Range
For Each Cellule In Range(Range("r1"), Range("r65536").End(xlUp))
If IsEmpty(Cellule) = True Then
Cellule.Interior.ColorIndex = 8
End If
Next Cellule
End Sub
--
Cela convient-il?
----
Pierre Fauconnier
"C'est lorsqu'il y a un temps mort qu'il faut tuer le temps..."
(remplacer NOSPAM par pfi pour me répondre. Merci)
nosferalto wrote:
Merci,
Mais ma boucle reste tout le temps inifie...
meme en enlevant le cell...
@ suivre...
Nosferlato
-----Message d'origine-----
Bonjour,
Enlève le Cell.Select. De toute façon, tu n'en as pas besoin.
Salutations,
Daniel M.
"Nosferalto" <nosferalto@yahoo.fr> wrote in message
news:103a01c38367$2b2f34d0$a001280a@phx.gbl...
Bjr à tous !
Petit problème :
Je selectionne une colonne avec une macro.
Je souhaiterais que ma boucle s'arrete une fois la
derniere cellule rencontrée
qui peut etre vide ou non...
Car là elle tend vers l'infinie...
Avez vous une idée ?
Ne serait ce pas :
range("A65536").end(xlup) ?
Voici mon code :
Range("R1").Select
For Each cell In Range(ActiveCell, ActiveCell
(1, 2).End(xlDown)(1, 0))
' --- si la cellule est vide
If IsEmpty(cell) = True Then
cell.Select
cell.Interior.ColorIndex = 8
End If
1. Tu n'as pas besoin de sélectionner une cellule pour travailler dessus. 2. Je ne comprends par bien la complication de ta boucle for each ...
Ceci pourrait-il te convenir ?
Sub Test() Dim Cellule As Range
For Each Cellule In Range(Range("r1"), Range("r65536").End(xlUp)) If IsEmpty(Cellule) = True Then Cellule.Interior.ColorIndex = 8 End If Next Cellule End Sub
-- Cela convient-il? ---- Pierre Fauconnier "C'est lorsqu'il y a un temps mort qu'il faut tuer le temps..." (remplacer NOSPAM par pfi pour me répondre. Merci)
nosferalto wrote:
Merci, Mais ma boucle reste tout le temps inifie... meme en enlevant le cell... @ suivre... Nosferlato
-----Message d'origine----- Bonjour,
Enlève le Cell.Select. De toute façon, tu n'en as pas besoin.
Salutations,
Daniel M.
"Nosferalto" wrote in message news:103a01c38367$2b2f34d0$ Bjr à tous ! Petit problème : Je selectionne une colonne avec une macro. Je souhaiterais que ma boucle s'arrete une fois la derniere cellule rencontrée qui peut etre vide ou non... Car là elle tend vers l'infinie... Avez vous une idée ?
Ne serait ce pas : range("A65536").end(xlup) ?
Voici mon code :
Range("R1").Select
For Each cell In Range(ActiveCell, ActiveCell (1, 2).End(xlDown)(1, 0)) ' --- si la cellule est vide If IsEmpty(cell) = True Then cell.Select cell.Interior.ColorIndex = 8 End If
Next cell Nosferlato
.
Robert Dezan
Bonsoir, Voici une solution bien plus simple en une seule ligne :
Sub Macro1() Range("R1:R" + CStr([R65000].End(xlUp).Row)).SpecialCells(xlCellTypeBlanks).Interior.ColorIndex = 8 End Sub
Cordialement Robert Dezan
"Nosferalto" a écrit dans le message de news:103a01c38367$2b2f34d0$ Bjr à tous ! Petit problème : Je selectionne une colonne avec une macro. Je souhaiterais que ma boucle s'arrete une fois la derniere cellule rencontrée qui peut etre vide ou non... Car là elle tend vers l'infinie... Avez vous une idée ?
Ne serait ce pas : range("A65536").end(xlup) ?
Voici mon code :
Range("R1").Select
For Each cell In Range(ActiveCell, ActiveCell (1, 2).End(xlDown)(1, 0)) ' --- si la cellule est vide If IsEmpty(cell) = True Then cell.Select cell.Interior.ColorIndex = 8 End If
Next cell Nosferlato
Bonsoir,
Voici une solution bien plus simple en une seule ligne :
Sub Macro1()
Range("R1:R" +
CStr([R65000].End(xlUp).Row)).SpecialCells(xlCellTypeBlanks).Interior.ColorIndex
= 8
End Sub
Cordialement
Robert Dezan
"Nosferalto" <nosferalto@yahoo.fr> a écrit dans le message de
news:103a01c38367$2b2f34d0$a001280a@phx.gbl...
Bjr à tous !
Petit problème :
Je selectionne une colonne avec une macro.
Je souhaiterais que ma boucle s'arrete une fois la
derniere cellule rencontrée
qui peut etre vide ou non...
Car là elle tend vers l'infinie...
Avez vous une idée ?
Ne serait ce pas :
range("A65536").end(xlup) ?
Voici mon code :
Range("R1").Select
For Each cell In Range(ActiveCell, ActiveCell
(1, 2).End(xlDown)(1, 0))
' --- si la cellule est vide
If IsEmpty(cell) = True Then
cell.Select
cell.Interior.ColorIndex = 8
End If
Bonsoir, Voici une solution bien plus simple en une seule ligne :
Sub Macro1() Range("R1:R" + CStr([R65000].End(xlUp).Row)).SpecialCells(xlCellTypeBlanks).Interior.ColorIndex = 8 End Sub
Cordialement Robert Dezan
"Nosferalto" a écrit dans le message de news:103a01c38367$2b2f34d0$ Bjr à tous ! Petit problème : Je selectionne une colonne avec une macro. Je souhaiterais que ma boucle s'arrete une fois la derniere cellule rencontrée qui peut etre vide ou non... Car là elle tend vers l'infinie... Avez vous une idée ?
Ne serait ce pas : range("A65536").end(xlup) ?
Voici mon code :
Range("R1").Select
For Each cell In Range(ActiveCell, ActiveCell (1, 2).End(xlDown)(1, 0)) ' --- si la cellule est vide If IsEmpty(cell) = True Then cell.Select cell.Interior.ColorIndex = 8 End If
Next cell Nosferlato
nosferalto
Bonjour ! Merci, J'ai reussi à l'integrer, mais maintenant jai un autre probleme : je fais une premiere boucle For ... elle marche très bien, mais dès que j'attaque la seconde il m'est impossible de selectionner une cellule precise j'arrive à selectionner toutes les cellule avant mais pas la cellule concernée... Peut etre faut il reinitialiser Range ? Je ne comprends plus rien... Merci encore une fois pour votre aide si précieuse ! Nosferalto (ps je suis debutant) Voici mon code :
' compte le nbr de cellule ds une colonne Fin_Col = "" Range("I1").Select Fin_Col = Range("I1").SpecialCells (xlCellTypeLastCell).Row Fin_Col = Fin_Col + 1 MsgBox Fin_Col
Dim cellA As Range Dim cellB Dim Ad_cellA Dim n Dim cellBval Dim cellAval cellA = "" cellB = "" cellBval = "" cellAval = "" n = "0"
' --- Premiere boucle qui marche très bien
cellB = Range("J1").Value For Each cellA In Range(Range("I1"), Range("I65536").End (xlDown)) MsgBox (cellA) cellAval = cellA.Address
' For Each cellB In Range(Range("J1"), Range ("J65536").End(xlDown)) MsgBox "!!! ANCIEN !!! cellB : " & (cellB) ' cellB.Select If n >= 1 Then ' cellB = "" ' cellBval = "" cellB = Selection.Offset(rowOffset:=(n), columnOffset:=1).Value cellBval = Selection.Offset(rowOffset:=(n), columnOffset:=1).Address
End If MsgBox (cellA.Row) If cellA.Row < Fin_Col Then MsgBox "Valeur cellA = " & (cellA) MsgBox "Valeur cellB = " & (cellB) MsgBox "Ligne CellA numéro = " & (cellA.Row) If cellA.Value = "Q" Then If cellB = "7 : Won - In force" Then MsgBox "Valeur cellAval = " & (cellAval) Range(cellAval).Select Selection.Interior.Color = RGB(255, 0, 0) ' ---- 0.0.0 = noir
Range("I1").Select End If Else If cellA.Value = "S" Then
' --- 1 - 10, 10B, 10C, 6A, 6B, 8A,8B, 8C, 10A, 10B, 10C, 10D If cellB = "6 : Won - Not in force" Or cellB = "6A : Won - Not confirmed" Or cellB = "7 : Won - In force" Or cellB = "9 : Cancelled" Then
End If ' Exit For Else Exit For End If n = n + 1 Next MsgBox "FIN The..." Range("J1").Select
' --- 2 eme boucle ou se situe le problème : cellA = "" cellB = "" cellAval = "" cellBval = "" n = "0"
cellB = Range("N1").Value ' --- !!! Dans la ligne ci-dessous je souhaiterais selectionner la cellule "J1" _ Mais il me prend toujours la cellule cell - 1 cad "I1" _ la je ne vois vraiment pas... !!! For Each cellA In Range(Range("J1"), Range("I65536").End (xlDown)) If n >= 1 Then cellB = Selection.Offset(rowOffset:=(n), columnOffset:=3).Value cellBval = Selection.Offset(rowOffset:=(n), columnOffset:=3).Address End If MsgBox (cellA.Row) If cellA.Row < Fin_Col Then MsgBox "Valeur cellA = " & (cellA) MsgBox "Valeur cellB = " & (cellB) MsgBox "Ligne CellA numéro = " & (cellA.Row) If cellA = "1 : New Project Identified" Or cellA = "2 : Preliminary work/Pre- qualification" Or cellA = "3 : Offer in preparation" Then If IsEmpty(cellB) = False Then MsgBox (cellBval) Range(cellBval).Select Selection.Interior.Color = RGB(255, 204, 102)
Range("J1").Select End If End If ' Exit For Else Exit For End If n = n + 1 Next
-----Message d'origine----- Bonjour
1. Tu n'as pas besoin de sélectionner une cellule pour travailler dessus.
2. Je ne comprends par bien la complication de ta boucle for each ...
Ceci pourrait-il te convenir ?
Sub Test() Dim Cellule As Range
For Each Cellule In Range(Range("r1"), Range ("r65536").End(xlUp))
If IsEmpty(Cellule) = True Then Cellule.Interior.ColorIndex = 8 End If Next Cellule End Sub
-- Cela convient-il? ---- Pierre Fauconnier "C'est lorsqu'il y a un temps mort qu'il faut tuer le temps..."
(remplacer NOSPAM par pfi pour me répondre. Merci)
nosferalto wrote:
Merci, Mais ma boucle reste tout le temps inifie... meme en enlevant le cell... @ suivre... Nosferlato
-----Message d'origine----- Bonjour,
Enlève le Cell.Select. De toute façon, tu n'en as pas besoin.
Salutations,
Daniel M.
"Nosferalto" wrote in message news:103a01c38367$2b2f34d0$ Bjr à tous ! Petit problème : Je selectionne une colonne avec une macro. Je souhaiterais que ma boucle s'arrete une fois la derniere cellule rencontrée qui peut etre vide ou non... Car là elle tend vers l'infinie... Avez vous une idée ?
Ne serait ce pas : range("A65536").end(xlup) ?
Voici mon code :
Range("R1").Select
For Each cell In Range(ActiveCell, ActiveCell
(1, 2).End(xlDown)(1, 0)) ' --- si la cellule est vide If IsEmpty(cell) = True Then cell.Select cell.Interior.ColorIndex = 8 End If
Next cell Nosferlato
.
.
Bonjour !
Merci, J'ai reussi à l'integrer,
mais maintenant jai un autre probleme :
je fais une premiere boucle For ...
elle marche très bien, mais dès que j'attaque la seconde
il m'est impossible de selectionner une cellule precise
j'arrive à selectionner toutes les cellule avant mais pas
la cellule concernée...
Peut etre faut il reinitialiser Range ?
Je ne comprends plus rien...
Merci encore une fois pour votre aide si précieuse !
Nosferalto (ps je suis debutant)
Voici mon code :
' compte le nbr de cellule ds une colonne
Fin_Col = ""
Range("I1").Select
Fin_Col = Range("I1").SpecialCells
(xlCellTypeLastCell).Row
Fin_Col = Fin_Col + 1
MsgBox Fin_Col
Dim cellA As Range
Dim cellB
Dim Ad_cellA
Dim n
Dim cellBval
Dim cellAval
cellA = ""
cellB = ""
cellBval = ""
cellAval = ""
n = "0"
' --- Premiere boucle qui marche très bien
cellB = Range("J1").Value
For Each cellA In Range(Range("I1"), Range("I65536").End
(xlDown))
MsgBox (cellA)
cellAval = cellA.Address
' For Each cellB In Range(Range("J1"), Range
("J65536").End(xlDown))
MsgBox "!!! ANCIEN !!! cellB : " & (cellB)
' cellB.Select
If n >= 1 Then
' cellB = ""
' cellBval = ""
cellB = Selection.Offset(rowOffset:=(n),
columnOffset:=1).Value
cellBval = Selection.Offset(rowOffset:=(n),
columnOffset:=1).Address
End If
MsgBox (cellA.Row)
If cellA.Row < Fin_Col Then
MsgBox "Valeur cellA = " & (cellA)
MsgBox "Valeur cellB = " & (cellB)
MsgBox "Ligne CellA numéro = " &
(cellA.Row)
If cellA.Value = "Q" Then
If cellB = "7 : Won - In
force" Then
MsgBox "Valeur cellAval
= " & (cellAval)
Range(cellAval).Select
Selection.Interior.Color =
RGB(255, 0, 0) ' ---- 0.0.0 = noir
Range("I1").Select
End If
Else
If cellA.Value = "S" Then
' --- 1 - 10, 10B, 10C, 6A,
6B, 8A,8B, 8C, 10A, 10B, 10C, 10D
If cellB = "6 : Won - Not in
force" Or cellB = "6A : Won - Not confirmed" Or cellB
= "7 : Won - In force" Or cellB = "9 : Cancelled" Then
End If
' Exit For
Else
Exit For
End If
n = n + 1
Next
MsgBox "FIN The..."
Range("J1").Select
' --- 2 eme boucle ou se situe le problème :
cellA = ""
cellB = ""
cellAval = ""
cellBval = ""
n = "0"
cellB = Range("N1").Value
' --- !!! Dans la ligne ci-dessous je souhaiterais
selectionner la cellule "J1" _
Mais il me prend toujours la cellule cell - 1 cad "I1" _
la je ne vois vraiment pas... !!!
For Each cellA In Range(Range("J1"), Range("I65536").End
(xlDown))
If n >= 1 Then
cellB = Selection.Offset(rowOffset:=(n),
columnOffset:=3).Value
cellBval = Selection.Offset(rowOffset:=(n),
columnOffset:=3).Address
End If
MsgBox (cellA.Row)
If cellA.Row < Fin_Col Then
MsgBox "Valeur cellA = " & (cellA)
MsgBox "Valeur cellB = " & (cellB)
MsgBox "Ligne CellA numéro = " &
(cellA.Row)
If cellA = "1 : New Project
Identified" Or cellA = "2 : Preliminary work/Pre-
qualification" Or cellA = "3 : Offer in preparation" Then
If IsEmpty(cellB) = False Then
MsgBox (cellBval)
Range(cellBval).Select
Selection.Interior.Color =
RGB(255, 204, 102)
Range("J1").Select
End If
End If
' Exit For
Else
Exit For
End If
n = n + 1
Next
-----Message d'origine-----
Bonjour
1. Tu n'as pas besoin de sélectionner une cellule pour
travailler dessus.
2. Je ne comprends par bien la complication de ta boucle
for each ...
Ceci pourrait-il te convenir ?
Sub Test()
Dim Cellule As Range
For Each Cellule In Range(Range("r1"), Range
("r65536").End(xlUp))
If IsEmpty(Cellule) = True Then
Cellule.Interior.ColorIndex = 8
End If
Next Cellule
End Sub
--
Cela convient-il?
----
Pierre Fauconnier
"C'est lorsqu'il y a un temps mort qu'il faut tuer le
temps..."
(remplacer NOSPAM par pfi pour me répondre. Merci)
nosferalto wrote:
Merci,
Mais ma boucle reste tout le temps inifie...
meme en enlevant le cell...
@ suivre...
Nosferlato
-----Message d'origine-----
Bonjour,
Enlève le Cell.Select. De toute façon, tu n'en as pas
besoin.
Salutations,
Daniel M.
"Nosferalto" <nosferalto@yahoo.fr> wrote in message
news:103a01c38367$2b2f34d0$a001280a@phx.gbl...
Bjr à tous !
Petit problème :
Je selectionne une colonne avec une macro.
Je souhaiterais que ma boucle s'arrete une fois la
derniere cellule rencontrée
qui peut etre vide ou non...
Car là elle tend vers l'infinie...
Avez vous une idée ?
Ne serait ce pas :
range("A65536").end(xlup) ?
Voici mon code :
Range("R1").Select
For Each cell In Range(ActiveCell,
ActiveCell
(1, 2).End(xlDown)(1, 0))
' --- si la cellule est vide
If IsEmpty(cell) = True Then
cell.Select
cell.Interior.ColorIndex = 8
End If
Bonjour ! Merci, J'ai reussi à l'integrer, mais maintenant jai un autre probleme : je fais une premiere boucle For ... elle marche très bien, mais dès que j'attaque la seconde il m'est impossible de selectionner une cellule precise j'arrive à selectionner toutes les cellule avant mais pas la cellule concernée... Peut etre faut il reinitialiser Range ? Je ne comprends plus rien... Merci encore une fois pour votre aide si précieuse ! Nosferalto (ps je suis debutant) Voici mon code :
' compte le nbr de cellule ds une colonne Fin_Col = "" Range("I1").Select Fin_Col = Range("I1").SpecialCells (xlCellTypeLastCell).Row Fin_Col = Fin_Col + 1 MsgBox Fin_Col
Dim cellA As Range Dim cellB Dim Ad_cellA Dim n Dim cellBval Dim cellAval cellA = "" cellB = "" cellBval = "" cellAval = "" n = "0"
' --- Premiere boucle qui marche très bien
cellB = Range("J1").Value For Each cellA In Range(Range("I1"), Range("I65536").End (xlDown)) MsgBox (cellA) cellAval = cellA.Address
' For Each cellB In Range(Range("J1"), Range ("J65536").End(xlDown)) MsgBox "!!! ANCIEN !!! cellB : " & (cellB) ' cellB.Select If n >= 1 Then ' cellB = "" ' cellBval = "" cellB = Selection.Offset(rowOffset:=(n), columnOffset:=1).Value cellBval = Selection.Offset(rowOffset:=(n), columnOffset:=1).Address
End If MsgBox (cellA.Row) If cellA.Row < Fin_Col Then MsgBox "Valeur cellA = " & (cellA) MsgBox "Valeur cellB = " & (cellB) MsgBox "Ligne CellA numéro = " & (cellA.Row) If cellA.Value = "Q" Then If cellB = "7 : Won - In force" Then MsgBox "Valeur cellAval = " & (cellAval) Range(cellAval).Select Selection.Interior.Color = RGB(255, 0, 0) ' ---- 0.0.0 = noir
Range("I1").Select End If Else If cellA.Value = "S" Then
' --- 1 - 10, 10B, 10C, 6A, 6B, 8A,8B, 8C, 10A, 10B, 10C, 10D If cellB = "6 : Won - Not in force" Or cellB = "6A : Won - Not confirmed" Or cellB = "7 : Won - In force" Or cellB = "9 : Cancelled" Then
End If ' Exit For Else Exit For End If n = n + 1 Next MsgBox "FIN The..." Range("J1").Select
' --- 2 eme boucle ou se situe le problème : cellA = "" cellB = "" cellAval = "" cellBval = "" n = "0"
cellB = Range("N1").Value ' --- !!! Dans la ligne ci-dessous je souhaiterais selectionner la cellule "J1" _ Mais il me prend toujours la cellule cell - 1 cad "I1" _ la je ne vois vraiment pas... !!! For Each cellA In Range(Range("J1"), Range("I65536").End (xlDown)) If n >= 1 Then cellB = Selection.Offset(rowOffset:=(n), columnOffset:=3).Value cellBval = Selection.Offset(rowOffset:=(n), columnOffset:=3).Address End If MsgBox (cellA.Row) If cellA.Row < Fin_Col Then MsgBox "Valeur cellA = " & (cellA) MsgBox "Valeur cellB = " & (cellB) MsgBox "Ligne CellA numéro = " & (cellA.Row) If cellA = "1 : New Project Identified" Or cellA = "2 : Preliminary work/Pre- qualification" Or cellA = "3 : Offer in preparation" Then If IsEmpty(cellB) = False Then MsgBox (cellBval) Range(cellBval).Select Selection.Interior.Color = RGB(255, 204, 102)
Range("J1").Select End If End If ' Exit For Else Exit For End If n = n + 1 Next
-----Message d'origine----- Bonjour
1. Tu n'as pas besoin de sélectionner une cellule pour travailler dessus.
2. Je ne comprends par bien la complication de ta boucle for each ...
Ceci pourrait-il te convenir ?
Sub Test() Dim Cellule As Range
For Each Cellule In Range(Range("r1"), Range ("r65536").End(xlUp))
If IsEmpty(Cellule) = True Then Cellule.Interior.ColorIndex = 8 End If Next Cellule End Sub
-- Cela convient-il? ---- Pierre Fauconnier "C'est lorsqu'il y a un temps mort qu'il faut tuer le temps..."
(remplacer NOSPAM par pfi pour me répondre. Merci)
nosferalto wrote:
Merci, Mais ma boucle reste tout le temps inifie... meme en enlevant le cell... @ suivre... Nosferlato
-----Message d'origine----- Bonjour,
Enlève le Cell.Select. De toute façon, tu n'en as pas besoin.
Salutations,
Daniel M.
"Nosferalto" wrote in message news:103a01c38367$2b2f34d0$ Bjr à tous ! Petit problème : Je selectionne une colonne avec une macro. Je souhaiterais que ma boucle s'arrete une fois la derniere cellule rencontrée qui peut etre vide ou non... Car là elle tend vers l'infinie... Avez vous une idée ?
Ne serait ce pas : range("A65536").end(xlup) ?
Voici mon code :
Range("R1").Select
For Each cell In Range(ActiveCell, ActiveCell
(1, 2).End(xlDown)(1, 0)) ' --- si la cellule est vide If IsEmpty(cell) = True Then cell.Select cell.Interior.ColorIndex = 8 End If
Next cell Nosferlato
.
.
nosferalto
Re-moi ! Pour le message probleme sur le range : Je viens de trouver ! alors là j'ai honte ! j'ai oublier de changer un i en j... M'enfin ! Nosferalto
-----Message d'origine----- Bonjour
1. Tu n'as pas besoin de sélectionner une cellule pour travailler dessus.
2. Je ne comprends par bien la complication de ta boucle for each ...
Ceci pourrait-il te convenir ?
Sub Test() Dim Cellule As Range
For Each Cellule In Range(Range("r1"), Range ("r65536").End(xlUp))
If IsEmpty(Cellule) = True Then Cellule.Interior.ColorIndex = 8 End If Next Cellule End Sub
-- Cela convient-il? ---- Pierre Fauconnier "C'est lorsqu'il y a un temps mort qu'il faut tuer le temps..."
(remplacer NOSPAM par pfi pour me répondre. Merci)
nosferalto wrote:
Merci, Mais ma boucle reste tout le temps inifie... meme en enlevant le cell... @ suivre... Nosferlato
-----Message d'origine----- Bonjour,
Enlève le Cell.Select. De toute façon, tu n'en as pas besoin.
Salutations,
Daniel M.
"Nosferalto" wrote in message news:103a01c38367$2b2f34d0$ Bjr à tous ! Petit problème : Je selectionne une colonne avec une macro. Je souhaiterais que ma boucle s'arrete une fois la derniere cellule rencontrée qui peut etre vide ou non... Car là elle tend vers l'infinie... Avez vous une idée ?
Ne serait ce pas : range("A65536").end(xlup) ?
Voici mon code :
Range("R1").Select
For Each cell In Range(ActiveCell, ActiveCell
(1, 2).End(xlDown)(1, 0)) ' --- si la cellule est vide If IsEmpty(cell) = True Then cell.Select cell.Interior.ColorIndex = 8 End If
Next cell Nosferlato
.
.
Re-moi !
Pour le message probleme sur le range :
Je viens de trouver !
alors là j'ai honte !
j'ai oublier de changer un i en j...
M'enfin !
Nosferalto
-----Message d'origine-----
Bonjour
1. Tu n'as pas besoin de sélectionner une cellule pour
travailler dessus.
2. Je ne comprends par bien la complication de ta boucle
for each ...
Ceci pourrait-il te convenir ?
Sub Test()
Dim Cellule As Range
For Each Cellule In Range(Range("r1"), Range
("r65536").End(xlUp))
If IsEmpty(Cellule) = True Then
Cellule.Interior.ColorIndex = 8
End If
Next Cellule
End Sub
--
Cela convient-il?
----
Pierre Fauconnier
"C'est lorsqu'il y a un temps mort qu'il faut tuer le
temps..."
(remplacer NOSPAM par pfi pour me répondre. Merci)
nosferalto wrote:
Merci,
Mais ma boucle reste tout le temps inifie...
meme en enlevant le cell...
@ suivre...
Nosferlato
-----Message d'origine-----
Bonjour,
Enlève le Cell.Select. De toute façon, tu n'en as pas
besoin.
Salutations,
Daniel M.
"Nosferalto" <nosferalto@yahoo.fr> wrote in message
news:103a01c38367$2b2f34d0$a001280a@phx.gbl...
Bjr à tous !
Petit problème :
Je selectionne une colonne avec une macro.
Je souhaiterais que ma boucle s'arrete une fois la
derniere cellule rencontrée
qui peut etre vide ou non...
Car là elle tend vers l'infinie...
Avez vous une idée ?
Ne serait ce pas :
range("A65536").end(xlup) ?
Voici mon code :
Range("R1").Select
For Each cell In Range(ActiveCell,
ActiveCell
(1, 2).End(xlDown)(1, 0))
' --- si la cellule est vide
If IsEmpty(cell) = True Then
cell.Select
cell.Interior.ColorIndex = 8
End If
Re-moi ! Pour le message probleme sur le range : Je viens de trouver ! alors là j'ai honte ! j'ai oublier de changer un i en j... M'enfin ! Nosferalto
-----Message d'origine----- Bonjour
1. Tu n'as pas besoin de sélectionner une cellule pour travailler dessus.
2. Je ne comprends par bien la complication de ta boucle for each ...
Ceci pourrait-il te convenir ?
Sub Test() Dim Cellule As Range
For Each Cellule In Range(Range("r1"), Range ("r65536").End(xlUp))
If IsEmpty(Cellule) = True Then Cellule.Interior.ColorIndex = 8 End If Next Cellule End Sub
-- Cela convient-il? ---- Pierre Fauconnier "C'est lorsqu'il y a un temps mort qu'il faut tuer le temps..."
(remplacer NOSPAM par pfi pour me répondre. Merci)
nosferalto wrote:
Merci, Mais ma boucle reste tout le temps inifie... meme en enlevant le cell... @ suivre... Nosferlato
-----Message d'origine----- Bonjour,
Enlève le Cell.Select. De toute façon, tu n'en as pas besoin.
Salutations,
Daniel M.
"Nosferalto" wrote in message news:103a01c38367$2b2f34d0$ Bjr à tous ! Petit problème : Je selectionne une colonne avec une macro. Je souhaiterais que ma boucle s'arrete une fois la derniere cellule rencontrée qui peut etre vide ou non... Car là elle tend vers l'infinie... Avez vous une idée ?
Ne serait ce pas : range("A65536").end(xlup) ?
Voici mon code :
Range("R1").Select
For Each cell In Range(ActiveCell, ActiveCell
(1, 2).End(xlDown)(1, 0)) ' --- si la cellule est vide If IsEmpty(cell) = True Then cell.Select cell.Interior.ColorIndex = 8 End If