detection de cellule vide et copiage suite...
bonjour a tous et bonne année 2009
je reprends près les fetes mon sujet que j'ai essayé d'adapter a mon fichier et la j'ai un message d'erreur (erreur d'exécution 9 l'indice n'ppartient pas à la sélection) sur le :
C = Workbooks("TOTO 88F OP1 26-12-08 232108.xls").Sheets("p1").Range("B3").Value
ci joint la procédure employée et en fait ce nom de fichier évolue a chaque enregistrement et je ne sais comment faire pour qu'il soit reconnu systématiquement et correctement
sub enregistrement()
Application.ScreenUpdating = False
For Each wb In Workbooks
If wb.Name Like "*" & "*" & "*" Then Set wb1 = wb: Exit For
Next wb
If wb1 Is Nothing Then MsgBox "Impossibilité de continuer car le fichier n'est pas ouvert": Exit Sub
wb1.Activate
Sheets("Accueil").Select
Range("B3").Select
Range("B3").Copy
On Error Resume Next
Windows(Dossier_Chefdespe).Activate
Application.ScreenUpdating = False
Sheets("Global").Select
Range("E3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E6").Select
On Error GoTo 0
For Each wb In Workbooks
If wb.Name Like "*" & "*" & "*" Then Set wb1 = wb: Exit For
Next wb
If wb1 Is Nothing Then MsgBox "Impossibilité de continuer car le fichier n'est pas ouvert": Exit Sub
wb1.Activate
Sheets("p1").Select
Set a1b = Sheets("p1").Range("O12,O15,O18,O21,O24,O27")
Set a2b = Sheets("p1").Range("O42,O45,O48,O51,O54,O57")
Set a3b = Sheets("p1").Range("O72,O75,O78,O81,O84,O87")
Set myMultipleRange = Union(a1b, a2b, a3b)
C = Workbooks("TOTO 88F OP1 26-12-08 232108.xls").Sheets("p1").Range("B3").Value
With Workbooks(Dossier_Chefdespe).Sheets("Global")
Set x = .Range("E3:AR3").Find(C, , xlValues, xlWhole, , , False)
If Not x Is Nothing Then
Sheets("p1").myMultipleRange.Copy .Cells(6, x.Column)
Else
Set x = .Range("E3:AR3").Find("", , xlValues, xlWhole, , , False)
If Not x Is Nothing Then Sheets("p1").myMultipleRange.Copy .Cells(6, x.Column)
If Not x Is Nothing Then Sheets("p1").Range("B3").Copy x
End If
End With
ActiveWorkbook.Save
On Error Resume Next
'lecteurR = Left(Worksheets("admin").range("J3").value, 2)
ChDrive (lecteurR)
cheminRESEAU
'Dossier_reseau = Worksheets("admin").range("J3").value
QPath = Dossier_reseau
' Récupère l'ancien nom du fichier
QFic = Dir(QPath & x & " " & y & " " & Z & " " & "*" & ".xls")
' Le sauvegarde sous le nouveau nom
ActiveWorkbook.SaveAs Dossier_reseau & x & " " & y & " " & Z & " " & Format(Now, "dd-mm-yy hhnnss") & ".xls"
' Supprime l'ancien si existe
If QFic <> "" Then Kill QPath & QFic
If Err.Number <> 0 Then
'lecteurPC = Left(Worksheets("admin").range("K3").value, 2)
ChDrive (lecteurPC)
cheminPC
'Dossier_PCisole = Worksheets("admin").range("K3").value
QPath = Sheets("admin").Range("K3").Value
' Récupère l'ancien nom du fichier
QFic = Dir(QPath & x & " " & y & " " & Z & " " & "*" & ".xls")
' Le sauvegarde sous le nouveau nom
ActiveWorkbook.SaveAs Dossier_PCisole & x & " " & y & " " & Z & " " & Format(Now, "dd-mm-yy hhnnss") & ".xls"
' Supprime l'ancien si existe
If QFic <> "" Then Kill QPath & QFic
End If
On Error GoTo 0
'****************************************************************************************************
Application.DisplayFullScreen = False
Application.DisplayAlerts = False
Application.ScreenUpdating = True
ActiveWindow.Close
End Sub
merci pour votre aide