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

Pookiemeister

Active Member
Joined
Nov 26, 2015
Messages
316
Office Version
  1. 365
  2. 2010
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.
 

Some videos you may like

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,412
Office Version
  1. 365
Platform
  1. Windows
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,328
Messages
5,624,036
Members
416,007
Latest member
csf

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
Top