Attribute VB_Name = "ET"
Option Explicit

Sub ANG()
Attribute ANG.VB_ProcData.VB_Invoke_Func = "Normal.ET.ANG"
Dim NUMAWA As Integer
Dim code As String
Dim code2 As String
Dim cell As Range
Dim pctdone As Single
Dim i As Integer

Application.ScreenUpdating = False
Application.DisplayStatusBar = False

NUMAWA = InputBox("Entrer numéro d'AWA")
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "AWA": .Replacement.Text = "AWA" & NUMAWA: .Forward = True: .Wrap = wdFindContinue: .Format = False: .MatchCase = False: .MatchWholeWord = True: .MatchWildcards = False: .MatchSoundsLike = False: .MatchAllWordForms = False
        
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
    

    Dim objExcel As New Excel.Application
    
Dim exWb As Excel.Workbook

'Set exWb = objExcel.Workbooks.Open("\\SERVEURAFGROS\Shared Folders\public\GERALDINE database NE JAMAIS TOUCHER\database.xlsx")
Set exWb = objExcel.Workbooks.Open("C:\Users\AF\Desktop\database.xlsx")

ufProgress.LabelProgress.Width = 0
ufProgress.Show


'Code Barre 6Btls
For i = 1 To 600
pctdone = i / 600
    With ufProgress
        .LabelCaption.Caption = "1/6 - Processing Row " & i & " of 600 " & "- Code Barre 6Btls"
        .LabelProgress.Width = pctdone * (.FrameProgress.Width)
    End With
    DoEvents
    
code = exWb.Sheets("Feuil1").Cells(i, 5)
code2 = exWb.Sheets("Feuil1").Cells(i, 11)
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = code: .Replacement.Text = code2: .Forward = True: .Wrap = wdFindContinue: .Format = False: .MatchCase = False: .MatchWholeWord = True: .MatchWildcards = False: .MatchSoundsLike = False: .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
If i = 600 Then Unload ufProgress
If i = 600 Then ufProgress.LabelProgress.Width = 0
Next i

ufProgress.Show

'Code Barre 12Btls
For i = 1 To 600
pctdone = i / 600
    With ufProgress
        .LabelCaption.Caption = "2/6 - Processing Row " & i & " of 600 " & "- Code Barre 12Btls"
        .LabelProgress.Width = pctdone * (.FrameProgress.Width)
    End With
    DoEvents
    
code = exWb.Sheets("Feuil1").Cells(i, 6)
code2 = exWb.Sheets("Feuil1").Cells(i, 12)
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = code
        .Replacement.Text = code2
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
If i = 600 Then Unload ufProgress
If i = 600 Then ufProgress.LabelProgress.Width = 0
Next i

ufProgress.Show

'Degré alc.
For i = 1 To 600

pctdone = i / 600
    With ufProgress
        .LabelCaption.Caption = "3/6 - Processing Row " & i & " of 600 " & "- Degré Alc."
        .LabelProgress.Width = pctdone * (.FrameProgress.Width)
    End With
    DoEvents
    
code = exWb.Sheets("Feuil1").Cells(i, 2)
code2 = exWb.Sheets("Feuil1").Cells(i, 13)
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = code
        .Replacement.Text = code2
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
If i = 600 Then Unload ufProgress
If i = 600 Then ufProgress.LabelProgress.Width = 0

Next i

ufProgress.Show

'Code Domaine
For i = 1 To 600


pctdone = i / 600
    With ufProgress
        .LabelCaption.Caption = "4/6 - Processing Row " & i & " of 600 " & "- Code Domaine"
        .LabelProgress.Width = pctdone * (.FrameProgress.Width)
    End With
    DoEvents
    
code = exWb.Sheets("Feuil1").Cells(i, 1)
code2 = exWb.Sheets("Feuil1").Cells(i, 14)
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = code
        .Replacement.Text = code2
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
If i = 600 Then Unload ufProgress
If i = 600 Then ufProgress.LabelProgress.Width = 0

Next i

ufProgress.Show

'Code Ang 6Btls
For i = 1 To 600


pctdone = i / 600
    With ufProgress
        .LabelCaption.Caption = "5/6 - Processing Row " & i & " of 600 " & "- Code Anglais 6Btls"
        .LabelProgress.Width = pctdone * (.FrameProgress.Width)
    End With
    DoEvents
    
code = exWb.Sheets("Feuil1").Cells(i, 3)
code2 = exWb.Sheets("Feuil1").Cells(i, 9)
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = code
        .Replacement.Text = code2
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

If i = 600 Then Unload ufProgress
If i = 600 Then ufProgress.LabelProgress.Width = 0

Next i

ufProgress.Show

'Code Ang 12Btls
For i = 1 To 600


pctdone = i / 600
    With ufProgress
        .LabelCaption.Caption = "6/6 - Processing Row " & i & " of 600 " & "- Code Anglais 12Btls"
        .LabelProgress.Width = pctdone * (.FrameProgress.Width)
    End With
    DoEvents
    
code = exWb.Sheets("Feuil1").Cells(i, 4)
code2 = exWb.Sheets("Feuil1").Cells(i, 10)
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = code
        .Replacement.Text = code2
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

If i = 600 Then Unload ufProgress
If i = 600 Then ufProgress.LabelProgress.Width = 0

Next i

Application.ScreenUpdating = True
Application.DisplayStatusBar = True

exWb.Close

Set exWb = Nothing

End Sub

Sub test()

Dim code As String
Dim code2 As String
Dim cell As Range
Dim i As Integer


    Dim objExcel As New Excel.Application
    
Dim exWb As Excel.Workbook

Set exWb = objExcel.Workbooks.Open("C:\Users\AF\Desktop\database.xlsx")
    
'Code Barre 6Btls
For i = 1 To 600
    
code = exWb.Sheets("Feuil1").Cells(i, 3)
code2 = exWb.Sheets("Feuil1").Cells(i, 9)
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = code
        .Replacement.Text = code2
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
Next i

exWb.Close

Set exWb = Nothing

End Sub
