Autofit Method of Range Class Failed (Run Time Error 1004)
excel, vba
Solution
Try
Dim counterparty As String
counterparty = Sheet1.txt1.Text
Range("C5").Value = counterparty
Sheets("Bank Certification").Select
Columns("C:C").Autofit
Problem
This is just part of my code. the value from the textbox here already gets copied to the specific cell in the Bank Certification worksheet. I need to make sure that cell C5 is specifically fitted regardless of the length of the text i inputted in the textbox. I tried interchanging range with cells to no avail. This problem seems so simple but I don't know why it doesn't work... ``` Dim counterparty As String counterparty = Sheet1.txt1.Text Range("C5").Value = counterparty Sheets("Bank Certification").Select Range("C5").Select Selection.AutoFit ```