Runtime error '1004': Unable to set the Name property of the Font class

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
563
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
This the code that precedes the error message and calls the subroutine
Code:
Private Sub cmdbtnEnter_Click()
    Dim lLastRow As Long
    Dim ws As Worksheet
    Dim iStartNum As Integer
    
    Set ws = Sheets("Sheet1")
    iStartNum = 1
    Unload Me
    lLastRow = Cells(Rows.Count, "B").End(xlUp).Row + 1
    Set rngitem = Cells(lLastRow, "B")
    rngitem.Select
    rngitem.Value = Me.txtbxDatePerformed.Value
    rngitem.Offset(, 1) = Me.lblDate.Caption
    rngitem.Offset(, 2) = Me.cmbShift.Value
    rngitem.Offset(, 3) = Me.txtbxMaintEntryNum.Value
    rngitem.Offset(, 4) = Me.cmbLocation.Value
    rngitem.Offset(, 5) = Me.txtbxPrdct.Value
    rngitem.Offset(, 6) = Me.txtbxBotSz.Value
    rngitem.Offset(, 8) = SelectedItems
    rngitem.Offset(, 9) = Me.txtbxDuration.Value
    rngitem.Offset(, 12) = Me.cmbCompleted.Value
    Call Orientation
End Sub

VBA Code:
Sub Orientation()
    Dim c As Range
    For Each c In Range(Cells(2, 1), Cells(2, 14))
        c.Select
        c.Font.Name = "Calibri" '[B]Error occurs on this line[/B]
        c.Font.Size = 11
        c.Font.Bold = False
        With Selection
            .EntireColumn.AutoFit
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            .WrapText = True
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
            .MergeCells = False
        End With
    Next c
End Sub

This worked at one point and the only thing that changed is I locked the cells that contain formula's which is in Range("A2:A40"). Now I am getting the error "Runtime error '1004': Unable to set the Name property of the Font class" Any advice would be greatly appreciated. Thank you.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
If the cells are locked & the sheet is protected, then you will need to unprotect the sheet at the start of the code & re-protect it at the end.
 
Upvote 0

Forum statistics

Threads
1,215,009
Messages
6,122,674
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top