autofit and auto border script

 Private Sub Worksheet_Change(ByVal Target As Range)

    ' Check if any change is made in the used range of the sheet

    If Not Intersect(Target, Me.UsedRange) Is Nothing Then

        If Target.Value <> "" Then

            ' Apply borders

            With Target.Borders

                .LineStyle = xlContinuous

                .Weight = xlThin

            End With

            ' AutoFit the column based on the entered value

            Target.EntireColumn.AutoFit

        End If

    End If

End Sub