I
Izran
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
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