+ Reply to Thread
Results 1 to 3 of 3

sum bold cells in a column...repeat across multiple columns

  1. #1
    Registered User
    Join Date
    02-02-2013
    Location
    Boston, MA
    MS-Off Ver
    Excel 2010
    Posts
    2

    sum bold cells in a column...repeat across multiple columns

    I wrote this VBA code to sum only the cells in column "H" that are bold font and place the answer after the last row.
    Now I'd like to enhance it by adding a loop that repeats the same function across multiple columns, e.g. H through AF.

    Im not sure how to code a nested loop that would perform the same summation across multiple columns...any assistance would be appreciated...



    Sub bold()

    Dim row As Long
    Dim LastRow As Long

    '---------------------------------------------------------------------------------------
    ' Use the Count property of Rows to detect the number of rows in the active sheet
    ' Detect the last row of data in a column, working from the bottom of the worksheet up
    '---------------------------------------------------------------------------------------

    LastRow = Range("H" & Rows.Count).End(xlUp).row

    For row = 1 To LastRow
    If Range("H" & row).Font.bold = True Then
    Range("H" & LastRow + 1).Value = Range("H" & LastRow + 1).Value + Range("H" & row).Value
    End If
    Next row

    End Sub

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,517

    Re: sum bold cells in a column...repeat across multiple columns

    Try this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    02-02-2013
    Location
    Boston, MA
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: sum bold cells in a column...repeat across multiple columns

    This worked...thanks very much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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