1 pièce(s) jointe(s)
Non prise en compte de condition (if) dans l'éxecution d'une macro
Bonjour,
Je viens vers vous car j'ai rencontré un problème.
En effet, j'ai une macro qui me permet de prélever des données aléatoirement avec certaines conditions.
Cependant, la macro ne respectent pas la condition if et me renvoie des valeurs erronées.
Ci-joint un extrait du fichier.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Sub Date_exclus()
'
Dim tTab
'
fm_MsgBoxINPUT.Show
'
iRow = Cells(Rows.Count, 1).End(xlUp).Row
tTab = Range("A5:H" & iRow)
'
Do
iFlag = Int(Rnd * UBound(tTab, 1)) + 1
If Mid(tTab(iFlag, 1), 2, 2) > Range("K1") And Mid(tTab(iFlag, 1), 4, 2) > Range("K2") And tTab(iFlag, 8) = "FN " Then
tTab(iFlag, 1) = 0
iLig = iLig + 1
Sheets("Feuil2").Range("A" & iLig & ":H" & iLig).Value = Range("A" & iFlag + 1 & ":H" & iFlag + 1).Value
End If
iFlag1 = iFlag1 + 1
Loop Until iLig = 83 Or iFlag1 = 30000
'
End Sub |
merci pour votre aide :).
1 pièce(s) jointe(s)
Non prise en compte de condition (if) dans l'éxecution d'une macro
bonjour
je pense que ce sont tes variables avec des formats différents qui causent ton problème.
bonne journée