1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| Dim chemin As String
Sub btn_parcourir_Click()
With Application.FileDialog(msoFileDialogOpen)
With .Filters
.Clear
.Add "Feuille Microsoft Office Excel", "*.xls;*.xlsx", 1
End With
.AllowMultiSelect = False
chemin = joindre
If chemin <> "" Then Range("B6").Value = chemin
End With
End Sub
Function joindre()
joindre = Application.GetOpenFilename
End Function
Sub conversion()
Dim xls As Excel.Application
Set xls = CreateObject("Excel.Application")
xls.Workbooks.Open (chemin)
nom = xls.ActiveWorkbook.Name
Dim PlageB As Object, PlageE As Object, plageF As Object, Tmp As String, Tmp2 As String, destinataire As String, _
concurrent1 As String, concurrent2 As String, Ean As String, NewEan As String, Price As String, NewPrice As String, _
Price2 As String, Newprice2 As String
Dim fichier
fichier = ThisWorkbook.Path & "\" & "ExportThomasdoublerang.csv"
Set PlageB = xls.Range("B3:B" & Cells(Rows.Count, 2).End(xlUp).Row)
Set PlageE = xls.Range("E3:E" & Cells(Rows.Count, 5).End(xlUp).Row)
Set plageF = xls.Range("F3:F" & Cells(Rows.Count, 5).End(xlUp).Row)
Open "ExportThomasdoublerang.csv" For Output As #1
destinataire = "000160"
concurrent1 = "RANG01"
concurrent2 = "RANG02"
For Ligne = 1 To PlageB.Rows.Count
Ean = PlageB.Cells(Ligne, 1).Value
NewEan = String(13 - Len(Trim(Ean)), "0") & Ean
Price = PlageE.Cells(Ligne, 1).Value
Price = Price * 100
NewPrice = String(6 - Len(Trim(Price)), "0") & Price
Price2 = plageF.Cells(Ligne, 1).Value
Price2 = Price2 * 100
Newprice2 = String(6 - Len(Trim(Price2)), "0") & Price2
Tmp = destinataire & NewEan & concurrent1 & NewPrice
Print #1, Tmp
Tmp2 = destinataire & NewEan & concurrent2 & Newprice2
Print #1, Tmp2
Next Ligne
Close
End Sub |
Partager