+ Reply to Thread
Results 1 to 8 of 8

Determining total column width of visible cells

  1. #1
    Registered User
    Join Date
    12-06-2008
    Location
    miami
    Posts
    9

    Determining total column width of visible cells

    Hello All,
    I have had great luck getting help from the brilliant members of this forum, so I thought I would try again with a new challenge.

    I am trying to resize a picture on a worksheet to fit a dynamic measurement(the size of the page is different depending on the contents in cells).
    I am doing this all in VBA.

    so what I have come up with is that I need to
    1) determine the total column width of only the non-hidden(visible) cells.
    2) resize my picture to those measurements, so I can get an exact fit, and it doesn't create a new page break, by going over.

    I have found some code on forums, and am thinking of something like this as a solution(although I don't know how to complete it):

    For summing column widths:


    Please Login or Register  to view this content.
    -or-


    Please Login or Register  to view this content.


    then I would have to use that total column width number as either inches or pixels to resize the width and height to fit on one page of the activesheet.


    for that I was thinking of something like this:

    Please Login or Register  to view this content.

    I appreciate everyones help, thank you,
    -alex
    Last edited by alexramo; 12-26-2008 at 02:40 PM. Reason: spelling error

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Why don't you use the
    Please Login or Register  to view this content.
    , or
    Please Login or Register  to view this content.
    approach. If you know that you will be covering say A1:F1 and there may (or may not) be hidden columns in that range, then
    Please Login or Register  to view this content.
    will give you the width of the columns and then you can just make your picture that width less say a fixed amount.

    HTH

    rylo

  3. #3
    Registered User
    Join Date
    12-06-2008
    Location
    miami
    Posts
    9

    got this from someone

    someone had sent me this:

    Please Login or Register  to view this content.
    it seems to work, however I'm now trying to figure out how to use or convert the value it gives me to resize m picture to fit the one page.

    thank you.

  4. #4
    Registered User
    Join Date
    12-06-2008
    Location
    miami
    Posts
    9

    follow up to range.width

    does range.width take into account the hidden cells, or does it exclude them in the measurment?

  5. #5
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    It excludes them. Try it on a test file. Show the width before you hide a column, then hide a column and see how it comes out.

    Please Login or Register  to view this content.
    rylo

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    The width of hidden columns / height of hidden rows is zero ...
    Last edited by shg; 12-24-2008 at 01:11 PM.
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Registered User
    Join Date
    12-06-2008
    Location
    miami
    Posts
    9
    Thank you very much for all your help again, everybody.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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