Results 1 to 3 of 3

change macro for height rows / columns in mm

Threaded View

  1. #1
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    change macro for height rows / columns in mm

    Hello to all.
    The attached macro found on the net:
    Option Explicit
    
    Sub SetColumnWidthMM(ColNo As Long, mmWidth As Integer)
    ' changes the column width to mmWidth
    Dim w As Single
    
        If ColNo < 1 Or ColNo > 255 Then Exit Sub
        Application.ScreenUpdating = False
        
        w = Application.CentimetersToPoints(mmWidth / 10)
        While Columns(ColNo + 1).Left - Columns(ColNo).Left - 0.1 > w
            Columns(ColNo).ColumnWidth = Columns(ColNo).ColumnWidth - 0.1
        Wend
        While Columns(ColNo + 1).Left - Columns(ColNo).Left + 0.1 < w
            Columns(ColNo).ColumnWidth = Columns(ColNo).ColumnWidth + 0.1
        Wend
    End Sub
    
    Sub SetRowHeightMM(RowNo As Long, mmHeight As Integer)
    ' changes the row height to mmHeight
        If RowNo < 1 Or RowNo > 65536 Then Exit Sub
        Rows(RowNo).RowHeight = Application.CentimetersToPoints(mmHeight / 10)
    End Sub
    
    'This example macro shows how you can set the row height for row 3 and the column width for column C to 3.5 cm:
    
    Sub ChangeWidthAndHeight()
    
        SetColumnWidthMM 1, 8 '<<< colonna 1,8 = A L=8mm
        SetRowHeightMM 3, 8 '<<< riga 3,8 = riga 3 L=8mm
            
    End Sub
    They are not accurate.
    you can change the calculation with this macro?

        
        'Sub rigacolonna()
    
        'Selection.RowHeight = (295.2 / 100) * 10 ' <<< 10 = height rows choice
        Selection.ColumnWidth = (45.9 / 100) * 10 '<<< 10 = width colums choice
    
       ' End Sub
    Last edited by max_max; 12-10-2016 at 03:45 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 03-21-2015, 08:18 PM
  2. Change macro from columns to rows
    By joseph.minner in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-07-2013, 12:57 PM
  3. Allow hide/unhide of columns/rows but not height/width adjustment?
    By drew.j.harrison in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-19-2013, 11:43 PM
  4. Macro to change Height of rows which are highlighted in Yellow
    By SecretaryExcel in forum Excel General
    Replies: 3
    Last Post: 08-15-2012, 10:52 AM
  5. macro to change rows to columns
    By faptronic in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-07-2011, 10:58 AM
  6. [SOLVED] lock up height & width of the rows and columns?
    By manharji in forum Excel General
    Replies: 0
    Last Post: 07-29-2010, 10:28 PM
  7. [SOLVED] change excel row height without showing hidden rows
    By LL in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-15-2005, 02:06 PM

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