VLOOKUP VBA error

khawla

New Member
Joined
Jun 27, 2018
Messages
2
Hi,
I want to realise a programme with vlookup but the programme dis not working.
Code:
Sub VLookup()    
    Dim sRes As String
    Dim F1, F2 As Worksheet
    Dim LastLig1 As Long
    Dim plage As Range
    Dim C As Range
    Dim i As Integer
    Dim rs As String
    Dim Resultat As Range
    
    Set F1 = Worksheets("fichier existant")
    Set F2 = Worksheets("fichier importé")
    Set plage = F2.Range("G1", F2.Range("G65536").End(xlUp))
    'LastLig1 = F2.Cells(Rows.Count, "A").End(xlUp).Row
    'For ligne = 2 To LastLig1
    i = 1
    For Each C In plage
    i = i + 1
    rs = F2.Range("G" + CStr(i)).Value
     F2.Range("Z" + CStr(i)).Value = (Application.VLookup("rs", F1.Range("G:G"), 0, False))
    If IsError(F2.Range("Z" + CStr(i)).Value) Then
        F2.Range("Z" + CStr(i)).Value = old
    Else
    F2.Range("Z" + CStr(i)).Value = Nouveau
    End If
    Next C
    
    
    'Debug.Print rs
    
    
End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi, what is the error it returns?
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top