Pookiemeister
Well-known Member
- Joined
- Jan 6, 2012
- Messages
- 626
- Office Version
- 365
- 2010
- Platform
- Windows
This the code that precedes the error message and calls the subroutine
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.
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.