Re : selectionner un fichier sur un autre disque en vba
RE Michel,
voici mon fichier:
http://cjoint.com/?guty0MR5ct
et la macro a modifier
Private Sub cmdEnregistrer_Click()
Dim lig As Long
Dim choixLig As Long
Dim col As Long
Dim choixCol As Long
' Trouver la ligne
choixLig = 0
For lig = 7 To 256
If Range("E7") = 0 Then choixLig = 7: Exit For
If Range("E" & lig) = Range("E1") Then choixLig = lig: Exit For
If Range("E" & lig) = 0 And Range("F3") > 1 Then
lig = Range("E65536").End(xlUp).Row + 1
Cells(lig, 5) = Range("E1")
choixLig = lig: Exit For
End If
Next lig
Cells(choixLig, 5) = Range("E1")
' If choixLig = 0 Then
' MsgBox "L'enregistrement n'est pas possible", vbCritical + vbOKOnly, "Erreur"
' Exit Sub
' End If
' Trouver la colonne
choixCol = 0
For col = 6 To 9
If Cells(choixLig, col) = 0 Then
choixCol = col
Exit For
End If
Next col
If choixCol = 0 Then
MsgBox "L'enregistrement n'est pas possible", vbCritical + vbOKOnly, "Erreur"
Exit Sub
End If
' Afficher le résultat
Cells(choixLig, choixCol).Value = Range("I1").Value
'and
Sheets("récap").Select
Ligne = Range("A65536").End(xlUp).Row + 1
Cells(Ligne, 1) = Sheets("tableau").Range("E1")
Cells(Ligne, 2) = Sheets("tableau").Range("H1")
Cells(Ligne, 3) = Sheets("tableau").Range("G1")
Cells(Ligne, 4) = Sheets("tableau").Range("I1")
'and
ce que je désire c'est qu'au lieu de copier les cellules sur la feuille calcul c'est de les copier dans un autre fichier sur un autre disque dur
'and
Sheets("calcul").Select
Ligne = Range("A65536").End(xlUp).Row + 1
Cells(Ligne, 1) = Sheets("tableau").Range("E1")
Cells(Ligne, 2) = Sheets("tableau").Range("H1")
Cells(Ligne, 3) = Sheets("tableau").Range("G1")
Cells(Ligne, 4) = Sheets("tableau").Range("I1")
'and
Worksheets("tableau").Select
'And
ActiveWorkbook.save
End Sub
Bon WE
Bpol