+ Reply to Thread
Results 1 to 6 of 6

Apply the code for entire row 4 help

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Apply the code for entire row 4 help

    Hi Friends,
    I have amended the code but it's for columns. I want this formatting for entire row 4 only and not for columns. Because it's disturbing my program if there is any data using ':' sign then the same formatting is applied which I don't want.

    Sub BoldText()
        Dim x As Long
        Dim rngCell As Range
        Range("G4").FormulaR1C1 = _
            "=IF(Information!R[3]C[6]="""","""",""Name of the student: ""& Information!R[3]C[6])"
        If Not Intersect(ActiveCell, Columns("a:r")) Is Nothing Then
            For Each rngCell In Cells(ActiveCell.Row, "A").Resize(, 18).Cells
                With rngCell
                                        If .Value Like "*[:]*" Then
                        If .HasFormula Then .Formula = .Value
                        .Characters.Font.Bold = True
                        x = InStr(.Value, ":")
                        .Characters(x).Font.Bold = False
                    End If
                End With
            Next rngCell
        End If
        MsgBox "Done!", 64
    End Sub
    The ':' sign is not changing to bold. I want to bold ':' sign too.

    Will you now please amend the code for entire row 4?

    Any help will be appreciated.

    Thanking you.
    Sincerely,

    mso3

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Apply the code for entire row 4 help

    Maybe:

    Sub BoldText()
        Dim x As Long
        Dim rngCell As Range
        Range("G4").FormulaR1C1 = _
            "=IF(Information!R[3]C[6]="""","""",""Name of the student: ""& Information!R[3]C[6])"
        If Not Intersect(ActiveCell, Columns("a:r")) Is Nothing Then
            For Each rngCell In Cells(4, "A").Resize(, 18).Cells
                With rngCell
                                        If .Value Like "*[:]*" Then
                        If .HasFormula Then .Formula = .Value
                        .Characters.Font.Bold = True:End If
    
                        x = InStr(.Value, ":")
                        .Characters(x).Font.Bold = True
                                End With
            Next rngCell
        End If
        MsgBox "Done!", 64
    End Sub
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: Apply the code for entire row 4 help

    No, it's not working fine. It bolds the entire text. I want the name in normal text here 'Robert' should be in a normal/regular font and not bold.

    Please see the attachment.

    Thank you.
    Attached Files Attached Files

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Apply the code for entire row 4 help

    Probably should rewrite thus but:

    Sub BoldText()
        Dim x As Long
        Dim rngCell As Range
        Range("G4").FormulaR1C1 = _
            "=IF(Information!R[3]C[6]="""","""",""Name of the student: ""& Information!R[3]C[6])"
        If Not Intersect(ActiveCell, Columns("a:r")) Is Nothing Then
            For Each rngCell In Cells(4, "A").Resize(, 18).Cells
                With rngCell
                        If .HasFormula Then
                        .Formula = .Value: .Characters.Font.Bold = True: End If
    
                        x = InStr(1, rngCell, ":")
                        If x Then
                        .Characters(x).Font.Bold = True
                        .Characters(x + 1).Font.Bold = False
                                              End If:      End With
            Next rngCell
        End If
        MsgBox "Done!", 64
    End Sub

  5. #5
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: Apply the code for entire row 4 help

    Hi xladept,
    Thank you. Now it's working fine.

    Thank you for solution.

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Apply the code for entire row 4 help

    You're welcome and thanks for the rep!

+ 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. Apply Macro to entire workbook
    By Msteenbeke in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-27-2012, 03:44 PM
  2. Apply Percentage to Entire Worksheet
    By joesmithf1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-01-2007, 01:28 AM
  3. HOW DO I APPLY A FORMULA FOR AND ENTIRE ROW?
    By jcpayne in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-19-2006, 01:10 PM
  4. How to apply a format to an entire workbook
    By mdeanda in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-17-2005, 02:06 PM
  5. Re: I would like to apply the same calculation to an entire row
    By mnirula in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-25-2005, 06:06 PM

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.6.0 RC 1