+ Reply to Thread
Results 1 to 7 of 7

Unable to set the bold property of the font class

  1. #1
    Izran
    Guest

    Unable to set the bold property of the font class

    I cannot seem to figure out how to make a cells contents bold when
    referencing them with the cells function. I keep getting unable to set
    hte bold property of the font class.


    Specific Section of code:


    iRowCountTo = iRowCountTo + 1
    Sh2.Cells(iRowCountTo, 1).Value = _
    Sh1.Cells(iRowCountFrom, 2).Value
    Sh2.Cells(iRowCountTo, 1).Cells.Font.Bold = True
    Sh2.Cells(iRowCountTo, 3).Value = _
    Sh1.Cells(iRowCountFrom, 3).Value
    Sh2.Cells(iRowCountTo, 3).Cells.Font.Bold = True




    The Whole Subroutine:


    Sub Air_Commodity_View()


    Dim Sh1 As Worksheet
    Dim Sh2 As Worksheet
    Dim Sh3 As Worksheet


    Dim iRowCountFrom As Integer, iColCountFrom As Integer
    Dim iRowCountTo As Integer, iColCountTo As Integer
    Dim iColumnCountMMM As Integer


    Dim rFromCell As Range
    Dim rToCell As Range
    Dim rLookupTable As Range
    Dim iListMax As Integer


    iRowCountTo = 9
    iRowCountFrom = 4
    iColumnCountTo = 2
    iColumnCountFrom = 2


    Set Sh1 = Sheets("Air_List")
    Set Sh2 = Sheets("Commodity_Entry")
    Set Sh3 = Sheets("MMM Index")


    Set rLookupTable = Sh3.Range("MMM_TABLE")


    Sh2.Range("A10:C65536") = Empty


    iListMax = Sheets("Air_List").Range("A1")
    For iRowCountFrom = 4 To iListMax + 3
    If Not IsEmpty(Sh1.Cells(iRowCountFrom, 2).Value) Then
    iRowCountTo = iRowCountTo + 1
    Sh2.Cells(iRowCountTo, 1).Value = _
    Sh1.Cells(iRowCountFrom, 2).Value
    Sh2.Cells(iRowCountTo, 1).Cells.Font.Bold = True
    Sh2.Cells(iRowCountTo, 3).Value = _
    Sh1.Cells(iRowCountFrom, 3).Value
    Sh2.Cells(iRowCountTo, 3).Cells.Font.Bold = True


    For iColCountMMM = 4 To 31
    If Not IsEmpty(Sh1.Cells(iRowCountFrom, _
    iColCountMMM).Value) Then
    iRowCountTo = iRowCountTo + 1
    Sh2.Cells(iRowCountTo, 2).Value = _
    Sh1.Cells(iRowCountFrom, iColCountMMM).Value
    Sh2.Cells(iRowCountTo, 3).Value = _
    Application.VLookup(Sh1.Cells(iRowCountFrom,
    iColCountMMM).Value, rLookupTable, 2, False)
    End If
    Next iColCountMMM
    End If


    iRowCountTo = iRowCountTo + 1


    Next iRowCountFrom


    End Sub



    Regards,
    MPManzi


  2. #2
    JE McGimpsey
    Guest

    Re: Unable to set the bold property of the font class

    Is Sh2 protected?

    In article <[email protected]>,
    "Izran" <[email protected]> wrote:

    > I cannot seem to figure out how to make a cells contents bold when
    > referencing them with the cells function. I keep getting unable to set
    > hte bold property of the font class.
    >
    >
    > Specific Section of code:
    >
    >
    > iRowCountTo = iRowCountTo + 1
    > Sh2.Cells(iRowCountTo, 1).Value = _
    > Sh1.Cells(iRowCountFrom, 2).Value
    > Sh2.Cells(iRowCountTo, 1).Cells.Font.Bold = True
    > Sh2.Cells(iRowCountTo, 3).Value = _
    > Sh1.Cells(iRowCountFrom, 3).Value
    > Sh2.Cells(iRowCountTo, 3).Cells.Font.Bold = True
    >


  3. #3
    Chip Pearson
    Guest

    Re: Unable to set the bold property of the font class

    > Is Sh2 protected?

    I thought of that, too. But the line of code above the Bold line
    puts a value on Sh2, so I assumed that the sheet was not
    protected.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "JE McGimpsey" <[email protected]> wrote in message
    news:[email protected]...
    > Is Sh2 protected?
    >
    > In article
    > <[email protected]>,
    > "Izran" <[email protected]> wrote:
    >
    >> I cannot seem to figure out how to make a cells contents bold
    >> when
    >> referencing them with the cells function. I keep getting
    >> unable to set
    >> hte bold property of the font class.
    >>
    >>
    >> Specific Section of code:
    >>
    >>
    >> iRowCountTo = iRowCountTo + 1
    >> Sh2.Cells(iRowCountTo, 1).Value = _
    >> Sh1.Cells(iRowCountFrom, 2).Value
    >> Sh2.Cells(iRowCountTo, 1).Cells.Font.Bold = True
    >> Sh2.Cells(iRowCountTo, 3).Value = _
    >> Sh1.Cells(iRowCountFrom, 3).Value
    >> Sh2.Cells(iRowCountTo, 3).Cells.Font.Bold = True
    >>




  4. #4
    Izran
    Guest

    Re: Unable to set the bold property of the font class

    Sheet 2 is not protected.


  5. #5
    Izran
    Guest

    Re: Unable to set the bold property of the font class

    Something else perculiar: WHen I set a watch on Sh2.Cells(iRowCountTo,
    1) or the like, and I try to expand it in the watch box to its
    subdirectories, when I try to expand cells Excel crashes. Wondering if
    that has something to do with it - the program can't access the .cells
    subdirectory udner the object??????


  6. #6
    Bernie Deitrick
    Guest

    Re: Unable to set the bold property of the font class

    Izran,

    While I wasn't able to reproduce your crash, you could try changing

    Sh2.Cells(iRowCountTo, 1).Cells.Font.Bold = True

    to

    Sh2.Cells(iRowCountTo, 1).Font.Bold = True

    HTH,
    Bernie
    MS Excel MVP


    "Izran" <[email protected]> wrote in message
    news:[email protected]...
    >I cannot seem to figure out how to make a cells contents bold when
    > referencing them with the cells function. I keep getting unable to set
    > hte bold property of the font class.
    >
    >
    > Specific Section of code:
    >
    >
    > iRowCountTo = iRowCountTo + 1
    > Sh2.Cells(iRowCountTo, 1).Value = _
    > Sh1.Cells(iRowCountFrom, 2).Value
    > Sh2.Cells(iRowCountTo, 1).Cells.Font.Bold = True
    > Sh2.Cells(iRowCountTo, 3).Value = _
    > Sh1.Cells(iRowCountFrom, 3).Value
    > Sh2.Cells(iRowCountTo, 3).Cells.Font.Bold = True
    >
    >
    >
    >
    > The Whole Subroutine:
    >
    >
    > Sub Air_Commodity_View()
    >
    >
    > Dim Sh1 As Worksheet
    > Dim Sh2 As Worksheet
    > Dim Sh3 As Worksheet
    >
    >
    > Dim iRowCountFrom As Integer, iColCountFrom As Integer
    > Dim iRowCountTo As Integer, iColCountTo As Integer
    > Dim iColumnCountMMM As Integer
    >
    >
    > Dim rFromCell As Range
    > Dim rToCell As Range
    > Dim rLookupTable As Range
    > Dim iListMax As Integer
    >
    >
    > iRowCountTo = 9
    > iRowCountFrom = 4
    > iColumnCountTo = 2
    > iColumnCountFrom = 2
    >
    >
    > Set Sh1 = Sheets("Air_List")
    > Set Sh2 = Sheets("Commodity_Entry")
    > Set Sh3 = Sheets("MMM Index")
    >
    >
    > Set rLookupTable = Sh3.Range("MMM_TABLE")
    >
    >
    > Sh2.Range("A10:C65536") = Empty
    >
    >
    > iListMax = Sheets("Air_List").Range("A1")
    > For iRowCountFrom = 4 To iListMax + 3
    > If Not IsEmpty(Sh1.Cells(iRowCountFrom, 2).Value) Then
    > iRowCountTo = iRowCountTo + 1
    > Sh2.Cells(iRowCountTo, 1).Value = _
    > Sh1.Cells(iRowCountFrom, 2).Value
    > Sh2.Cells(iRowCountTo, 1).Cells.Font.Bold = True
    > Sh2.Cells(iRowCountTo, 3).Value = _
    > Sh1.Cells(iRowCountFrom, 3).Value
    > Sh2.Cells(iRowCountTo, 3).Cells.Font.Bold = True
    >
    >
    > For iColCountMMM = 4 To 31
    > If Not IsEmpty(Sh1.Cells(iRowCountFrom, _
    > iColCountMMM).Value) Then
    > iRowCountTo = iRowCountTo + 1
    > Sh2.Cells(iRowCountTo, 2).Value = _
    > Sh1.Cells(iRowCountFrom, iColCountMMM).Value
    > Sh2.Cells(iRowCountTo, 3).Value = _
    > Application.VLookup(Sh1.Cells(iRowCountFrom,
    > iColCountMMM).Value, rLookupTable, 2, False)
    > End If
    > Next iColCountMMM
    > End If
    >
    >
    > iRowCountTo = iRowCountTo + 1
    >
    >
    > Next iRowCountFrom
    >
    >
    > End Sub
    >
    >
    >
    > Regards,
    > MPManzi
    >




  7. #7
    Izran
    Guest

    Re: Unable to set the bold property of the font class

    That did the trick!!! Was hung up on that for awhile, but fortunately
    I had other aspects to work on for the application. TYVM!!

    Regards,
    MPManzi


+ 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