Consulting

Results 1 to 4 of 4

Thread: Solved: string with asterisk

  1. #1
    VBAX Regular
    Joined
    Mar 2012
    Posts
    37
    Location

    Solved: string with asterisk

    hi,

    i am getting a string from a text file that is no longer than 20 characters in length. the string may contain asterisks that i want to remove.
    so for example, if the string is "***APP**LE**, i want the string to be "APPLE".
    i want to avoid writing the string to a cell. is this possible?

    thanks
    rem

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Hi there,

    You don't mention how (code example) you are getting the string(s), but have you tried Replace() ?

    [VBA]Sub exa()
    Dim myString As String

    myString = "**AP**PLE*"
    MsgBox Replace(myString, Chr(42), vbNullString)
    End Sub[/VBA]

  3. #3
    VBAX Regular
    Joined
    Mar 2012
    Posts
    37
    Location
    mark,
    just what i needed.
    thanks a lot!
    rem

  4. #4
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    You can also remove those asterisks in the worksheet:

    [VBA]
    Sub M_snb()
    activesheet.cells.replace "~*",""
    end Sub
    [/VBA]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •