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

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
626
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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
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,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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