Slow performance in looping and filling missing data I wrote some code that loops for specific data and then fills the missing cells in another sheet. The code works perfectly but it takes too much time to fill the missing cells (values).

What I tried to do is to Test if Cell B is blank or not , then I created 2 variables :


x for activesheet values which need to be filled and 
y for sheet 1 (source) and keep comparing until x match y to take the value in front of the specific data.


The code I came up with: 

  Sub TraiterNoms()
  Application.ScreenUpdating = False
  Application.DisplayAlerts = False
  Dim i As Variant
  Dim CompareRange As Variant
  Dim x As Variant
  Dim y As Variant
  Dim derlignE As Variant
  Dim derlignC As Variant


  derlignE = Range("A" &amp; Rows.Count).End(xlUp).Row
  derlignC = Sheets("Feuil1").Range("B" &amp; Rows.Count).End(xlUp).Row
  Set CompareRange = Sheets("Feuil1").Range("A:A").resize(derlignC, 1)

   For i = Range("A" &amp; Rows.Count).End(xlUp).Row To 1 Step -1
    If Range("B" &amp; i) = "" Then
      For Each x In Range("A:A").resize(derlignE, 1)
         For Each y In CompareRange
         If x = y Then x.Offset(0, 1) = y.Offset(0, 1)
        Next y
       Next x
      End If
    Next i
 Application.ScreenUpdating = True
 Application.DisplayAlerts = True
End Sub


I feel like I could improve this code to make it more fluent. Would that be over-complicated?

What's there to say about this code?
It looks like you just need VLookup. In column B1 of your active sheet you'll want =VLookup(A1,Feuil1!$A$1:$B$4,2,0). Make sure to edit Feuil1!$A$1:$B$4 to be the entire range you want. If your range is contiguous, no empty cells, Control+Shift+Down followed by Holding Shift+RightArrow ought to get you what you're after.

Edit:
Below you'll find code that does what you're attempting.

The reason why your initial code is so slow is you have a loop For Each ... Next within another loop. Inside this is checking each and every single one. and must go through the both lists. If in your first loop (ActiveSheet) you have 10 entries and your second loop (Feuil1) you have 15 entries you have to compare 150 times. If either list grows it will get slower and slower. By 
 refactoring you have the same outcome but achieved by a better, faster, way.

Strive for code that is self documenting. What is occurring should be apparent when you read it. Minimal effort should be needed to understand what is going on.

The code below has a main Sub that sets some variables and calls on functions to provide information to complete the required task.

Public Sub TraiterNoms()
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

    Dim actSheet As Worksheet
    Set actSheet = ActiveSheet

    Dim sourceSheet As Worksheet
    Set sourceSheet = ThisWorkbook.Worksheets("Feuil1")

    Dim lastFormulaRow As Long
    lastFormulaRow = actSheet.Cells(Rows.Count, 1).End(xlUp).Row
    Dim formulaRange As Range

    On Error GoTo NoBlankCells
    Set formulaRange = actSheet.Range(actSheet.Cells(1, 2), actSheet.Cells(lastFormulaRow, 2)).SpecialCells(xlCellTypeBlanks)
    On Error GoTo 0

    Dim lookupFormula As String
    lookupFormula = GetLookupFormula(formulaRange, sourceSheet, 2)
    formulaRange.Formula = lookupFormula
    Dim subArea As Range
    For Each subArea In formulaRange.Areas
        subArea.Value2 = subArea.Value2
    Next

CleanExit:
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    Exit Sub

NoBlankCells:
    Resume CleanExit

End Sub

Private Function GetLookupFormula(ByVal depositRange As Range, ByVal lookupSheet As Worksheet, ByVal lookupColumn As Long) As String
    Dim valueToMatch As String
    valueToMatch = depositRange.Cells(1, 1).Offset(ColumnOffset:=-1).Address(False, False)

    Dim lookupCells As String
    lookupCells = GetLookupCells(lookupSheet, lookupColumn)
    GetLookupFormula = "=Vlookup(" &amp; valueToMatch &amp; "," &amp; lookupCells &amp; "," &amp; lookupColumn &amp; ",0)"
End Function

Private Function GetLookupCells(ByVal sourceSheet As Worksheet, ByVal lookupColumn As Long) As String
    Dim lastRow As Long
    lastRow = sourceSheet.Cells(Rows.Count, "B").End(xlUp).Row

    Dim sourceRange As Range
    Set sourceRange = sourceSheet.Range(sourceSheet.Cells(1, 1), sourceSheet.Cells(lastRow, lookupColumn))

    GetLookupCells = sourceRange.Parent.Name &amp; "!" &amp; sourceRange.Address
End Function