Set Column WIDTH and HEIGHT to values in cells

  • I am wanting to set the column width based on the values in row 2, and the height based on values in Column A


    WIDTH Example B2=2, C2=10, D2=2. This would create WIDTHS of : Col B=2, Col C=10, Col D=2, Stop when the value is less than 1
    HEIGHT Example A3 (which is ROW 3) value=2, A4=5, A5=2, A6=5, A7=2, A8=18, A9=2. Stop when the value in Column A is less than 1

  • Re: Set Column WIDTH and HEIGHT to values in cells


    Code
    For Each r In Rows(1).SpecialCells(2,1)
       If r.Value > 1 Then r.ColumnWidth = r.Value
    Next
    
    
    For Each r In Columns(1).SpecialCells(2,1)
       If r.Value > 1 Then r.RowHeight = r.Value
    Next

    Regards,


    Wigi


    Excel MVP 2011-2014


    For more Excel memes: visit http://www.wimgielis.com ==> English articles ==> Excel memes


    -- Topics without [CODE] tags or a meaningful topic title, will be neglected by me (and probably many others as well) --

  • Re: Set Column WIDTH and HEIGHT to values in cells


    I did not realize that the row height dimension isn't the same as row width. I need to multiply the row height to get it in the same relationship as the row width.
    Example:


    If row width is 20, I want the row height to give me a square when I apply a border. It looks like the row height needs to be multiplied by somewhere between 5 and 6.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!