VBA n'accepte pas la valeur "FAUX"
F
bonjour,
j'ai un fichier avec le code ci-dessous qui va chercher des données (des 1 ou rien) dans d'autres fichiers pour les recopier.
ça marche très bien sauf quand dans le tableau source la valeur es "FAUX', le programme bloc en me disant qu'il ne trouve pas la semaine.
voici la formule dans le tableau source :
=SI(ET(C7<>"";NB.SI(fériés;C$89)=1);1;SI(NB.SI(fériés;C$89)=0;SI(OU(C7<>"";E7<>"");1;"")))
et voici le code dans le fichier destination :
Option Explicit
Dim Docdép, Fdép, i, j, Dte, N°Sem, Col, C
Dim FDVA, FDVB, Chemin
Sub Import()
Application.ScreenUpdating = False
Set Docdép = ActiveWorkbook
Set Fdép = ActiveSheet
FDVA = "Effectifs" & Year(Cells(4, "C").Value) & " FDVA.xlsx"
FDVB = "Effectifs" & Year(Cells(4, "C").Value) & " FDVB.xlsx"
Chemin = ThisWorkbook.Path & "\"
On Error GoTo PasDeFichier
Workbooks.Open Filename:=Chemin & FDVA
Workbooks.Open Filename:=Chemin & FDVB
On Error GoTo 0
Docdép.Activate
j = 3
While IsDate(Cells(4, j).Value) = True
Dte = Cells(4, j).Value
N°Sem = DateSerial(Year(Int(Dte) + (8 - Weekday(Int(Dte))) Mod 7 - 3), 1, 1)
N°Sem = CStr(((Int(Dte) - N°Sem - 3 + (Weekday(N°Sem) + 1) Mod 7)) \ 7 + 1)
On Error GoTo SemaineManquante
With Workbooks(FDVA).Sheets(N°Sem) '.Range("I96").Value
Col = .Range("C104:I104").Find(What:=Day(Dte), LookIn:=xlValues, LookAt:=xlWhole).Column
For i = 0 To 10
Cells(i + 5, j).Value = .Cells(i + 105, Col).Value
If UCase(Cells(i + 5, j)) = "FAUX" Then Cells(i + 5, j).ClearContents
Next i
End With
With Workbooks(FDVB).Sheets(N°Sem) '.Range("I96").Value
Col = .Range("C104:I104").Find(What:=Day(Dte), LookIn:=xlValues, LookAt:=xlWhole).Column
For i = 0 To 10
Cells(i + 16, j).Value = .Cells(i + 105, Col).Value
If UCase(Cells(i + 16, j)) = "FAUX" Then Cells(i + 16, j).ClearContents
Next i
End With
j = j + 1
Wend
Application.DisplayAlerts = False
Windows("Effectifs2014 FDVA.xlsx").Activate
ActiveWindow.Close
Windows("Effectifs2014 FDVB.xlsx").Activate
ActiveWindow.Close
Exit Sub
PasDeFichier:
MsgBox " Le fichier " & Chr(13) & " " & FDVA & Chr(13) & Chr(13) & _
" ou le fichier " & Chr(13) & " " & FDVB & Chr(13) & Chr(13) & " est introuvable !", 16
End
SemaineManquante:
MsgBox "La semaine " & N°Sem & " est introuvable !", 16
End Sub
merci d'avance pour vos retour et bon réveillon de Noël
Francky
Bonjour,
essaie =false
eric
Bonjour
Bonjour eriiic
En VBA c'est False ou True
Remplaces
If UCase(Cells(i + ...., j)) = "FAUX" Then ........
par
If Cells(i + ...., j) = False Then ........
F
Merci à tous les deux et encore bonnes fêtes de fin d'année,
Francky