+ Reply to Thread
Results 1 to 5 of 5

VLookup() Run-Time Error '1004'

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    VLookup() Run-Time Error '1004'

    Getting Run-Time Error '1004'
    Unable to get the Vlookup property of the WorksheetFunction Class

    I am not sure why. In Debug mode the variables are all correct.

     Dim drg_code As String,  disch_date As Date, facility As Variant, admit_type As String
     Dim drg_value As Variant, look_up_sheet As Worksheet, ds As Worksheet, data_array As Variant, drg_descrip As Variant
     Dim dyear As Variant, geo_zip As Variant, client_list As Worksheet, allowance As Variant, conc As Variant
     Dim Arrays As Worksheet
    
    Set look_up_sheet = ActiveWorkbook.Sheets("Sheet8")
    facility = look_up_sheet.Range("C5")
    Set client_list = ActiveWorkbook.Sheets("CLIENT LIST")
    geo_zip = Application.WorksheetFunction.vlookup(facility, client_list.Range("A1:E16"), 2, False)
    
    disch_date = Application.InputBox(prompt:="Enter the Discharge Date", Title:="Discharge Date", Type:=2)
        
        If Year(disch_date) = 2009 Then
            If disch_date <= 39993 Then
                dyear = "010109"
            Else
                dyear = "063009"
            End If
        Else
            dyear = Year(disch_date)
        End If
    
    admit_type = look_up_sheet.Range("F12")
    drg_code = Application.InputBox(prompt:="Enter the DRG Code", Title:="DRG Code", Type:=1)
    conc = dyear & admit_type & geo_zip
    Set Arrays = ActiveWorkbook.Sheets("Arrays")
    data_array = Application.WorksheetFunction.vlookup(conc, Arrays.Range("A1:E393"), 5, False)
    Set ds = ActiveWorkbook.Sheets(dyear)
    drg_value = Application.WorksheetFunction.vlookup(drg_code, ds.Range(data_array), 3, False)
    UNABLE TO ATTACH FILE AS THEY'RE HUGE.

  2. #2
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Re: VLookup() Run-Time Error '1004'

    this was previous code that worked.

    Dim drg_value As Variant, look_up_sheet As Worksheet, ds As Worksheet, data_sheet As Variant, data_array As Variant
    
    Set look_up_sheet = ActiveWorkbook.Sheets("Sheet8")
    data_sheet = look_up_sheet.Range("H3")
    Set ds = ActiveWorkbook.Sheets(data_sheet)
    data_array = look_up_sheet.Range("H2")
    drg_value = Application.WorksheetFunction.vlookup(look_up_sheet.Range("F13"), ds.Range(data_array), 3, False)
    look_up_sheet.Range("H4").Value = drg_value

  3. #3
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: VLookup() Run-Time Error '1004'

    Hi

    worked for me. Are you sure your sheet names are correct, and that there is relevant data to find?

    rylo

  4. #4
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Re: VLookup() Run-Time Error '1004'

    Yes, the sheets are name correctly. That was the first thing I checked. Several times.
    There is a significant amount of data to find.

    You checked the code in the top section? The second set of code is what I had working previously. I am trying to get away from hvaing to read values from the spreadsheet as I am having the user enter data through InputBox.

  5. #5
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Re: VLookup() Run-Time Error '1004'

    I was able to resolve the problem by defining drg_code as a Variant instead of the String it was defined as.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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