different approach to vlookup function vba

silentwolf

Well-known Member
Joined
May 14, 2008
Messages
1,216
Office Version
  1. 2016
Hi again,

sorry guys to be a pain about this issue.

Code:
Sub myLookUp()
    Dim lngLR As Long
    Dim i As Long
    Dim rngHoli As Range
    Dim intDoppelt As Integer
    
    lngLR = Cells(Rows.Count, 2).End(xlUp).row
    
    If Range("B2").value = "Germany" Then
        Set rngHoli = Application.Names("Holidays_Germany").RefersToRange.Rows
    Else
        Set rngHoli = Application.Names("Holidays_Austria").RefersToRange.Rows
    End If
    
    For i = 5 To lngLR
        Cells(i, 4) = WorksheetFunction.IfError(Application.VLookup(Cells(i, 2), rngHoli, 1, False), "")
    
    Next i
End Sub

whti this code above I am able to find holidays in either germany or in austria in a periode of time within my worksheet.
However as I need this dates for different calculations i.E. on some of the projects we need to work and others not so on holidays there must be a different hourly rate

So what other functions I could use to to that instead of giving my back the date?

Hope I explained myself good well enough.

Many thanks
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,213,506
Messages
6,114,027
Members
448,543
Latest member
MartinLarkin

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