+ Reply to Thread
Results 1 to 9 of 9

If error in UDF

Hybrid View

  1. #1
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,420

    If error in UDF

    I have data in col 1
    a1= alex berbec
    a2 = asoi
    a3= john travolta
    Etc
     Function UD(r as range)
    UD = split(r.value, " ") (1)
    End function
    I want take split first split
    In b1= berbex
    In b2 =asoi
    In b3 = travolta
    But in A2 = alex udf will be error
    How to else my udf
    function UD ( r as range)
    UD =iif(iserror(UD),r.value,split(r.value, " ")(1))
    End function
    But still error

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: If error in UDF

    Function UD(r As Range)
        Dim vSplit As Variant
        vSplit = Split(r.Value, " ")
        UD = vSplit(UBound(vSplit))
    End Function
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,420

    Re: If error in UDF

    I am sorri alpha frog
    In a10 = albert ender linon
    In b10 = ender

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

    Re: If error in UDF

    Perhaps.
    Function UD(r As Range)
        If InStr(r.Value, " ") Then
            UD = Split(r.value, " ") (1)
        End If
    End Function
    If posting code please use code tags, see here.

  5. #5
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,420

    Re: If error in UDF

    Norie
    If name in A11 = norie and in B11 = norie
    If name in a12 = norie prime b12 = prime
    If name in a13 = norie prime ayg b13 =prime

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: If error in UDF

    If you always want the second name if there is one, first otherwise, you might use
    Function UD(r As Range)
        Dim v
        v = Split(r.Value, " ")
        UD = v(1 + (UBound(v) = 0))
    End Function
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  7. #7
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,420

    Re: If error in UDF

    Its right job xlnitwit

  8. #8
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: If error in UDF

    This non UDF formula may work as well.

    Formula: copy to clipboard
    =IF(A1="","",IF(ISERROR(FIND(" ",A1)),A1,TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",50)),50,50))))

  9. #9
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,420

    Re: If error in UDF

    Thankyou friend

+ 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. VBA ERROR: run time error 1004: Application-defined or Object-defined error in excel 2013
    By AnanthKrishna in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2015, 06:16 AM
  2. [SOLVED] Run-tim error -2147467259(80004005): Automation error Unspecidied error
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-25-2014, 12:12 PM
  3. Excel macro (compile error. syntax error.) error
    By salar_younis in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2014, 06:11 AM
  4. Receiving following error “Complie error : syntax error” Help
    By masond3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-02-2012, 10:19 AM
  5. Error "run-time Error '1004': General Odbc Error
    By D4WNO77 in forum Access Tables & Databases
    Replies: 2
    Last Post: 07-16-2012, 09:55 AM
  6. Error 75 File/Path access error, sometimes Error 1004
    By smokebreak in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-16-2011, 02:35 PM
  7. Error Handling - On Error GoTo doesn't trap error successfully
    By David in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-16-2006, 02:10 PM

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