Sub releve_prix()
'
' enregistre_txt Macro
' Macro enregistrée le 21/10/2008 par David OREL
'
'
If FichierExiste("c:\prixconc.unp") = True Then Call efface_unp Else
ActiveWorkbook.RefreshAll
Dim lngHFile As Long
Dim Boucle As Integer
Dim nblig As Variant
Dim ean As Range
Dim prix As Range
Dim nomfeuille As String
Dim entete As String
Dim price As String
nomfeuille = ActiveSheet.Name
entete = "N1 " & nomfeuille
On Error GoTo gestionerreur
Set ean = Application.InputBox(prompt:="Sélectionnez les gencods produits", Title:="Selection EAN", Left:=160, Top:=80, Type:=8)
Range("a1").Activate
Set prix = Application.InputBox(prompt:="Sélectionnez les prix produits", Title:="Selection Prix", Left:=15, Top:=80, Type:=8)
With Application.WorksheetFunction
nblig = .CountA(ean)
lngHFile = FreeFile
Open "c:\prixconc.unp" For Append Shared As #lngHFile
Print #lngHFile, Trim(entete)
For Boucle = 1 To nblig Step 1
price = Format(prix.Cells(Boucle, 1).Value, "###0.###")
Print #lngHFile, Trim(ean.Cells(Boucle, 1).Value) & " " & Trim(price)
Next Boucle
Close #lngHFile
DoEvents
MsgBox "Fichier sauvegardé avec succès !", vbInformation + vbOKOnly, "Succès..."
End With
Exit Sub
gestionerreur:
MsgBox "Votre relevé ne sera pas généré", vbOKOnly
If vbOK = True Then Exit Sub
End Sub