+ Reply to Thread
Results 1 to 7 of 7

Thread: Apply format only a part of the cell values

  1. #1
    Registered User
    Join Date
    08-26-2010
    Location
    Venezuela
    MS-Off Ver
    Excel 2007
    Posts
    25

    Apply format only a part of the cell values

    Hi How are you?

    How do I format just part of the text obtained from the CONCATENATE function for example if I want the word Maria is in bold and the profession is in italics.

    I have put into practice the conditional formatting but I formatted the entire cell.

    I add a file that serves as an example.

    Thank you very much for your help.

    JuanM.
    Attached Files Attached Files

  2. #2
    Forum Guru Domski's Avatar
    Join Date
    12-14-2009
    MS-Off Ver
    What does it matter?
    Posts
    3,933

    Re: Apply format only a part of the cell values

    I'm afraid you can't format part of the results of a formula different to the rest.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    08-26-2010
    Location
    Venezuela
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Apply format only a part of the cell values

    Through VBA you can not or using another technique?

    Thanks

    Regards,

  4. #4
    Forum Guru Domski's Avatar
    Join Date
    12-14-2009
    MS-Off Ver
    What does it matter?
    Posts
    3,933

    Re: Apply format only a part of the cell values

    Try this:

    Sub test()
    
        Dim lngLoopRow As Long
        Dim lngLastRow As Long
        
        lngLastRow = Cells(Rows.Count, 2).End(xlUp).Row
        
        For lngLoopRow = 3 To lngLastRow
        
            With Range("F" & lngLoopRow)
            
                .Value = Range("B" & lngLoopRow) & " " & Range("C" & lngLoopRow) & " tiene " & _
                    Range("D" & lngLoopRow) & " años y su profesión es " & Range("E" & lngLoopRow)
    
                With .Characters(Start:=1, Length:=Len(Range("B" & lngLoopRow) & " " & Range("C" & lngLoopRow))).Font
                    .FontStyle = "Bold"
                End With
    
                With .Characters(Start:=Len(.Value) - Len(Range("E" & lngLoopRow)) + 1, Length:=Len(Range("E" & lngLoopRow))).Font
                    .FontStyle = "Italic"
                End With
                
            End With
    
        Next lngLoopRow
    
    End Sub

    Dom
    Last edited by Domski; 12-14-2010 at 11:46 AM.
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  5. #5
    Registered User
    Join Date
    08-26-2010
    Location
    Venezuela
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Apply format only a part of the cell values

    Dom hello thank you very much for the reply.

    The code works very well, there would be some way that will not erase the arguments of the concatenate function?

    Add the file to see that when I run the macro deletes the function arguments.

    Thank you very much for your help.

    Greetings
    Attached Files Attached Files

  6. #6
    Forum Guru Domski's Avatar
    Join Date
    12-14-2009
    MS-Off Ver
    What does it matter?
    Posts
    3,933

    Re: Apply format only a part of the cell values

    No, the only way is to do the whole thing including the concatenation using VBA.

    As I said it's not possible to format the result of a formula differently, you can only do this with fixed text strings.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  7. #7
    Registered User
    Join Date
    08-26-2010
    Location
    Venezuela
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Apply format only a part of the cell values

    Thanks for your answer.

    Best regards,

    JuanM

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0