+ Reply to Thread
Results 1 to 4 of 4

Find, Error Trap (Excel 2010 VBA)

Hybrid View

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

    Find, Error Trap (Excel 2010 VBA)

    I am trying to trap an error where the Value of hcpc(i) is not found on the data sheet. Partial code is below.

                    Set rngFound = lookupsht.Range("A1:H1257").Find(hcpc(i), , , xlWhole)
                              ruv(i) = rngFound.Offset(, 1).Value
    I tried this:

                    Set rngFound = lookupsht.Range("A1:H1257").Find(hcpc(i), , , xlWhole)
                    If ruv(i) = rngFound.Offset(, 1).Value Is Empty Then
                        feevalue(i) = 0
                        descrip(i) = "Unidentifiable Charge"
                        reason(i) = "HCPC Code Not Found in Fee Schedule"
                    Else
                        ruv(i) = rngFound.Offset(, 1).Value

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Find, Error Trap (Excel 2010 VBA)

                    Set rngFound = lookupsht.Range("A1:H1257").Find(hcpc(i), , , xlWhole)
                    If rngFound is nothing then
                        feevalue(i) = 0
                        descrip(i) = "Unidentifiable Charge"
                        reason(i) = "HCPC Code Not Found in Fee Schedule"
                    Else
                        ruv(i) = rngFound.Offset(, 1).Value
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Find, Error Trap (Excel 2010 VBA)

    Perhaps:

    Set rngFound = lookupsht.Range("A1:H1257").Find(HCPC(i), , , xlWhole)
    If rngFound Is Nothing Then
        feevalue(i) = 0
        descrip(i) = "Unidentifiable Charge"
        reason(i) = "HCPC Code Not Found in Fee Schedule"
    Else
        ruv(i) = rngFound.Offset(, 1).Value
    End If

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

    Re: Find, Error Trap (Excel 2010 VBA)

    works great guys! Thank you.
    Last edited by lloydgodin; 05-17-2012 at 03:40 PM.

+ 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