+ Reply to Thread
Results 1 to 3 of 3

Help with the HLOOKUP in VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    07-02-2014
    Location
    Florida, USA
    MS-Off Ver
    Office 2013
    Posts
    28

    Help with the HLOOKUP in VBA

    Hello

    I am creating a complex formula with UDF, this Hlookup is part of my complete formula.
    Meanwhile, I am working on this piece, not Sure what I am doing Wrong

    I try to conver "MonthCurrent" Variable in a Year because the MonthCurrent is 06/01/2014, so will be Year(6/1/2014) = 2014
    My Range called "DailyRates" is based per Year = 2014, 2015 ......

    Not sure what I am doing wrong, please if somebody can help... Thanks so much.

    Function Outputyear(MonthCurrent As Date) As String
    
    Dim DailyRatesRange As Range
    Set DailyRatesRange = Range("DailyRates")
    
    WorkingYear = Application.WorksheetFunction.Year(MonthCurrent)
    Outputyear = Application.WorksheetFunction.HLookup(WorkingYear, DailyRatesRange, 27, False)
    
    End Function

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Help with the HLOOKUP in VBA

    Use VBA's own Year function.
    WorkingYear = Year(MonthCurrent)
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    07-02-2014
    Location
    Florida, USA
    MS-Off Ver
    Office 2013
    Posts
    28

    Re: Help with the HLOOKUP in VBA

    Thanks Norie, Just in case you see that I make reference of Row with the number 27, did you know how can I make reference to use the row of the current cell. Is possible to do that?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. HLOOKUP Help. HLOOKUP links to Drop down list problems
    By finalmike in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-02-2013, 07:08 PM
  2. Hlookup
    By nicnicman in forum Excel General
    Replies: 4
    Last Post: 10-01-2011, 06:08 PM
  3. HLOOKUP in HLOOKUP, Base Estimate Table in Excel
    By gqdallas in forum Excel General
    Replies: 20
    Last Post: 10-19-2009, 01:41 PM
  4. [SOLVED] hlookup #N/A
    By stacyjhaskins in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1