+ Reply to Thread
Results 1 to 3 of 3

Using find function in a vba macro

Hybrid View

  1. #1
    Registered User
    Join Date
    01-13-2007
    Posts
    71

    Using find function in a vba macro

    Hey all.
    Once again, a weird query.
    How can I use the "FIND" function in a vba procedure?
    What i want is:
    I have a variable that comes up with email address I have in a sheet.
    IŽd like to use these email addresses to retrieve the string after the "@" character.
    I came up with the formula mid(variable, find(variable, "@"), 100) and it works fine in the spreadsheet but wont work if writen in the code.
    Does anyone knows how to code this function properly?
    thanks.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Using find function in a vba macro

    marcospaterson,

    You would use the application.worksheet object, with a little bit of code, like this: (assumes the email address is in cell A1)

    Sub getdomain()
        Dim domain As String
        domain = Right(Range("A1").Value, Len(Range("A1").Value) - Application.WorksheetFunction.Find("@", Range("A1")))
        MsgBox domain
    End Sub


    Hope that helps,
    tigeravatar

  3. #3
    Registered User
    Join Date
    01-13-2007
    Posts
    71

    Re: Using find function in a vba macro

    YEP! works fine!
    Thanx a lot tiger!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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