Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50070

Program was working fine, now im getting an error with "entire column.autofit"

$
0
0
this code keeps crashing on the line where I autofit the column.

it was working fine before..
Code:

Private Sub AddEquipBTN_Click()


Sheets("READ ONLY").Unprotect "123steel"

If Len(addEquipmentTB.Value) Then
        With Worksheets("READ ONLY")
            'Add entry to combobox
            equipmentcb2.AddItem addEquipmentTB.Value
            delEquipmentcb.AddItem addEquipmentTB.Value
            'Store entries on read only column f
            .Range("D" & Rows.Count).End(xlUp).Offset(1, 0).Value = addEquipmentTB.Value
            Columns("D:D").EntireColumn.AutoFit
            'Clear textbox
            Me.addEquipmentTB.Value = vbNullString
        End With
Else
    MsgBox ("Please Enter an Equipment")
   
End If

Sheets("READ ONLY").Protect "123steel"

End Sub


I have attached my workbook.
The password, whenever prompted, is 'steel123'

Thanks!
Attached Files

Viewing all articles
Browse latest Browse all 50070

Trending Articles