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
| Sub MEF()
Dim CIBLE, Code As Variant
Dim ligne As Integer
Dim Val As Range
Worksheets(1).Columns("C:C").Insert Shift:=xlToRight
Worksheets(1).Columns("N:N").Insert Shift:=xlToRight
Worksheets(1).Rows(1).Delete
ThisWorkbook.Worksheets(1).Cells(1, 3) = "ARTICLE "
For ligne = 3 To Range("B" & Rows.Count).End(xlUp).Row
If (IsEmpty(Range("B" & ligne))) Then
'MsgBox "Code Article Manquant à la ligne " & ligne
Exit Sub
Else
CIBLE = Range("B" & ligne)
' 10Jul2012000001 je dois convertir ce format date donc j'ai pensé à supprimer
'les 6 derniers caractéres mais ça me retourne erreur d'incomptaibilité
'Range("M" & ligne) = Left(Range("M" & ligne).Value, Len(Range("M" & ligne).Value - 6))
' sur cette colonne je veux faire une conversion du km au m pour cela je dois repérer le symbole
'contenu Details=0210/M///PROV situé entre"/"
If UCase(Range("O" & ligne)) Like "*/M/*" Then
Range ("O" & ligne) / 1000 = bat
bat = Range("O" & ligne)
End If
'la dans la colonne N j'aimerais mettre une date dans format yyyy-mm
'qui corresspond à la date de la colonne M sans le jour dd-yyyy-mm
ActiveSheet.Range("N" & ligne) = Format(Range("M" & ligne))
Feuil1.Range("K" & ligne).NumberFormat = "###0"
'MsgBox "Code Article " & CIBLE & " recherche"
Call Find(CIBLE, Code, ligne)
End If
Next ligne
End Sub
Sub Find(CIBLE, Code, ligne)
Dim x As Variant
Dim Val As Range
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set wbk = Workbooks.Open("C:\redirection\table.xlsx")
With wbk.Worksheets("Feuil1")
Set Val = .Columns("A:A").Find(CIBLE, LookIn:=xlValues)
If Not Val Is Nothing Then
'MsgBox "Le Code Article" & CIBLE & "est dans la ligne: " & Val.Row
Code = .Cells(Val.Row, 2).Value
ThisWorkbook.ActiveSheet.Range("C" & ligne) = Code
Else
'MsgBox "Code Article " & CIBLE & " non trouvée dans la table de correspondance"
End If
End With
wbk.Save
wbk.Close
Set wbk = Nothing
Application.ScreenUpdating = True
End Sub |