Hi All,
I am fairly new to the whole VBA thing and I am taking my first baby steps into Worksheet Functions.
The order of the day is vlookup. I have written the code below for my Vlookup but cannot figure out how to have the vlookup return the value from the "InitialRange" range into a specific cell.
All the lookup values are in column D and the referenced range "InitialRange" is in separate worksheet.
If i typed the normal (none VBA) lookup formula into the cells in column C, it would return the value. Need to do the same in VBA.
Thanks for all the help!
Sub GetCountry()
Dim Res As Variant
Dim CountryRange As Range
Dim InitialRange As Range
On Error Resume Next
Err.Clear
Set CountryRange = Range("D5:D50000")
Set InitialRange = Sheets("Country Code").Range("E2:F116")
Res = Application.WorksheetFunction.VLookup(CountryRange, InitialRange, 2, False).Value = ("C5")
If Err.Number = 0 Then
Else
End If
End Sub
I am fairly new to the whole VBA thing and I am taking my first baby steps into Worksheet Functions.
The order of the day is vlookup. I have written the code below for my Vlookup but cannot figure out how to have the vlookup return the value from the "InitialRange" range into a specific cell.
All the lookup values are in column D and the referenced range "InitialRange" is in separate worksheet.
If i typed the normal (none VBA) lookup formula into the cells in column C, it would return the value. Need to do the same in VBA.
Thanks for all the help!
Sub GetCountry()
Dim Res As Variant
Dim CountryRange As Range
Dim InitialRange As Range
On Error Resume Next
Err.Clear
Set CountryRange = Range("D5:D50000")
Set InitialRange = Sheets("Country Code").Range("E2:F116")
Res = Application.WorksheetFunction.VLookup(CountryRange, InitialRange, 2, False).Value = ("C5")
If Err.Number = 0 Then
Else
End If
End Sub