|
|
|
| [VBA] Boucle While par modjibe |
mardi 31 juillet 2007 à 15:29:43 |
Configuration: Windows XP Internet Explorer 7.0
Bonjour,
chez moi, de cette façon, le [And] et le [Or] fonctionne !
Option Explicit
Sub Test()
Dim cellExcel As Range
Dim a As Long, b As Long
Set cellExcel = Range("A1")
a = 10: b = 5
While ((a > b) Or (Left(cellExcel.Value, 5) <> "Total"))
'...
DoEvents
a = (a - 1)
ActiveCell.Offset(1, 0).Select
Set cellExcel = ActiveCell
Wend
Set cellExcel = Nothing
End Sub
'
Sub Test2()
Dim cellExcel As Range
Dim a As Long, b As Long
Range("A1").Select
Set cellExcel = ActiveCell
a = 7: b = 5
While ((a > b) And (Left(cellExcel.Value, 5) <> "Total"))
'...
DoEvents
a = (a - 1)
ActiveCell.Offset(1, 0).Select
Set cellExcel = ActiveCell
Wend
Set cellExcel = Nothing
End Sub
'
Lupin
|
Chez moi ça ne marche pas, il me fait une boucle alors que :
a = 612 b = 611 Left(cellExcel.Value,5) = "Total" Je comprends pas ... |
re:
As-tu utilisé la version [ And ] ou la version [ Or ] ( Test ou Test2 ) ? Lupin |
| 28/12 21h21 | [VBA] Boucle "do while not" et appel rec | Programmation | 28/12 21h40 | 2 |
| 03/03 19h05 | Algorithme d'une factorielle - boucle while | Programmation | 14/05 15h23 | 11 |
| 21/11 18h31 | [VBA] + boucle simple | Programmation | 21/11 21h36 | 1 |
| 14/02 11h54 | [Bash] Boucle while - export variable | Programmation | 15/02 07h45 | 3 |