email domain - Statistica Visual Basic - Statistica - Dell Community

email domain

email domain

This question is not answered

 I have a variable with email addresses. I want to create a new variable with just the email domain.

What formula can I use to extract the email domain?

All Replies
  • Hi, Mirror,

    The InStr function is probably your best ***.  The sample code below extracts the e-mail domain from an e-mail address and displays it in a message box.

    Sub Main

     Dim sEMAddress As String

     Dim sEMDomain As String

     sEMAddress = ""

     Dim lAtSymbol As Long

     lAtSymbol = InStr(1,sEMAddress,"@")

     sEMDomain = Right(sEMAddress,Len(sEMAddress) - lAtSymbol + 1)

     MsgBox (sEMDomain)

    End Sub

    I hope that you find this helpful.

  • Without VB... in the long variable name of your new variable you can use something like this:


    assuming your e-mail addresses are in v1 (first variable of the spreadsheet).

    use var name as necessary, replace 20 at the end with appropriate lenght if you want, you know what to do ...