Consulting

Results 1 to 2 of 2

Thread: Selecting: Just part of a string in a cell

  1. #1

    Selecting: Just part of a string in a cell

    I'm pretty sure this is a simple question, but the answer continues to elude me. How can you have vba select a portion of the contents of a cell. For example, if i wanted vba to select just the "press" in "express" inside just one cell, how would I go about doing this?

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    You could highlight (bold,color) that portion of the cell's contents. But selecting the characters can't be done. VBA doesn't interface with the formula editing box.

    Dim someCell As Range
    Dim subString As String
    Set someCell = Sheet1.Range("C10")
    subString = "press"
    someCell.Characters(InStr(1, CStr(someCell.Value) & subString, subString), Len(subString)).Font.Bold = True

Posting Permissions

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