+ Reply to Thread
Results 1 to 2 of 2

Set Column Width Based On Total Width Of Other Columns

  1. #1
    rayneraingoaway
    Guest

    Set Column Width Based On Total Width Of Other Columns

    I need help setting up the following Column Width macro in Excel:

    1. The "width" for Columns A, B, C, D should total 40.
    2. Columns B, C, D have been "autofit" based on the data entered.
    3. How would I set Column A "width" for all columns to still equal 40.

    For example:

    The new values are as follows:
    Column B = 13
    Column C = 10
    Column D = 5

    How would I set Column A "width" to 40 - (13,10,5)

  2. #2
    Jake Marx
    Guest

    Re: Set Column Width Based On Total Width Of Other Columns

    Hi,

    Something like this should work:

    Sub SetWidthOfColD()
    Dim sngWidth As Single

    With Sheets("mySheet")
    sngWidth = .Columns("A").ColumnWidth + _
    .Columns("B").ColumnWidth + _
    .Columns("C").ColumnWidth

    If (sngWidth < 40) Then
    .Columns("D").ColumnWidth = 40 - sngWidth
    End If
    End With
    End Sub

    --
    Regards,

    Jake Marx
    www.longhead.com


    [please keep replies in the newsgroup - email address unmonitored]

    rayneraingoaway wrote:
    > I need help setting up the following Column Width macro in Excel:
    >
    > 1. The "width" for Columns A, B, C, D should total 40.
    > 2. Columns B, C, D have been "autofit" based on the data entered.
    > 3. How would I set Column A "width" for all columns to still equal 40.
    >
    > For example:
    >
    > The new values are as follows:
    > Column B = 13
    > Column C = 10
    > Column D = 5
    >
    > How would I set Column A "width" to 40 - (13,10,5)




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1