Excel VBA – Set Column Width Exactly the Same in Other Workbooks – How to Code Examples

This Excel macro is useful if you have one or more Excel files where you want to set the column sizes exactly the same as the other workbook.

This script will take the current active (selected) workbook (Excel File) as a reference, get all the column widths from the active sheet (selected tab) and apply exactly the same widths to the active sheets (selected tabs) on all the other open workbooks (Excel files).

This VBA code will only affect active sheets.

Don’t forget to like and share if you found the code useful!


Sub MatchColumWidth()
    'Set column widths of all the other open workbooks to the same size as the current one
    'This script will only affect active sheets
    'Chi Brander, Inc.
    abookm = ActiveWorkbook.Name
    For Each wb In Application.Workbooks
        If wb.Name <> abookm Then
            For Each c In Workbooks(abookm).ActiveSheet.Columns
                wb.ActiveSheet.Columns(c.Column).ColumnWidth = c.ColumnWidth
            Next c
        End If
    Next wb

    MsgBox "Done."

End Sub


Posted by Excel Instructor: