+ Reply to Thread
Results 1 to 3 of 3

total width of all visible, contiguous columns occupied

  1. #1
    Forum Contributor
    Join Date
    01-13-2006
    Location
    Texas
    Posts
    161

    total width of all visible, contiguous columns occupied

    Below is the code I am using. I am pretty sure I am not referencing something consistently or fully.

    All I want to do is find the total width per worksheet (in inches, pixels, whatever) of the visible columns on each the worksheets in a single workbook. The sheets may have individual columns of various widths, but I want to be able to sync up the total overall widths for printing alignment. I just want to see with a msgbox what the total width of the sheet is, then move on to the next sheet. Tks in advance.

    Sub total_width()
    Dim totalwidth As Double

    Worksheets("Sheet1").Select
    For n = 2 To Worksheets.Count
    Worksheets(n).Activate
    For Each col In ActiveSheet.Columns("A:O")
    If Columns.Hidden = False Then
    If Columns.Cells(col, 1).Value <> "" Then
    totalwidth = totalwidth + col.ColumnWidth
    End If
    End If
    Next col
    z = MsgBox(totalwidth, , "Total Width of Columns")
    totalwidth = 0
    Next n
    End Sub

  2. #2
    Registered User
    Join Date
    01-09-2007
    Posts
    59
    Try this:

    Please Login or Register  to view this content.
    ska

  3. #3
    Forum Contributor
    Join Date
    01-13-2006
    Location
    Texas
    Posts
    161
    Thanks. That was very close to what I needed and I was able to tweak it the final bit. I appreciate the help.

+ 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