+ Reply to Thread
Results 1 to 6 of 6

Formatting a piece of the text in the formula box

Hybrid View

  1. #1
    Registered User
    Join Date
    03-26-2015
    Location
    Netherlands
    MS-Off Ver
    2013
    Posts
    75

    Formatting a piece of the text in the formula box

    I want to use VBA to insert text into a cell. The problem is that I want the inserted text to consist out of one character formatted in calibri, a space bar and then another character (D) formatted Wingdings 3 to make it appear as a double arrow. Is this possible?

  2. #2
    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: Formatting a piece of the text in the formula box

    Hi,

    It certainly is possible
        With ActiveCell
            .Font.Name = "Calibri"
            .Value2 = "A D"
            .Characters(3, 1).Font.Name = "Wingdings 3"
        End With
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Formatting a piece of the text in the formula box

    you need to change a Target range and insert only first character
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Cells.Count > 1 Then Exit Sub
        If Not Intersect(Target, Range("a1")) Is Nothing Then
    
            Application.EnableEvents = False
            Target.Value = Target.Value & "_D"
             Target.Characters(Start:=1, Length:=2).Font.Name = "Calibri"
             Target.Characters(Start:=3, Length:=1).Font.Name = "Wingdings 3"
             
            Application.EnableEvents = True
        End If
    End Sub

  4. #4
    Registered User
    Join Date
    03-26-2015
    Location
    Netherlands
    MS-Off Ver
    2013
    Posts
    75

    Re: Formatting a piece of the text in the formula box

    Thank you both! The only issue is that the first value can be 1 or 10000. So basically the number of characters where the wingdings part starts is variable.

  5. #5
    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: Formatting a piece of the text in the formula box

    If it's always the last character
    .Characters(Len(.Value), 1).Font.Name = "Wingdings 3"
    If it's not always the last character, how can it be identified?

  6. #6
    Registered User
    Join Date
    03-26-2015
    Location
    Netherlands
    MS-Off Ver
    2013
    Posts
    75

    Re: Formatting a piece of the text in the formula box

    It is always the last character so the code works wonderfully. Thanks again!

+ 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. [SOLVED] Import a piece of text from an other cell
    By alexhantson in forum Excel - New Users/Basics
    Replies: 7
    Last Post: 02-25-2015, 10:42 AM
  2. Searching for more than One piece of text
    By wings1080 in forum Excel General
    Replies: 4
    Last Post: 01-09-2015, 05:22 PM
  3. How to display output from one locked data piece and one client-input data piece?
    By tnovak in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-07-2014, 12:48 PM
  4. Replies: 4
    Last Post: 08-13-2014, 11:03 PM
  5. Piece together a formulae with text
    By TuboDieselOne in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-09-2014, 05:41 PM
  6. Searching if a cell contains a specific piece of text in an IF/OR formula
    By jshaw82 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-23-2013, 02:52 AM
  7. [SOLVED] editing a formula to insert a certain piece of text every 7th row
    By bite_tony in forum Excel General
    Replies: 10
    Last Post: 04-19-2012, 04:26 AM

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