+ Reply to Thread
Results 1 to 2 of 2

Button macro to setup Columns And rows for sheet.

Hybrid View

  1. #1
    Registered User
    Join Date
    02-08-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    80

    Button macro to setup Columns And rows for sheet.

    Hi

    Can someone please guide me how i can set the below macro to do loop until it gets to row 450

    Column A,B,E & F = 160 Pixel and Column C & D = 28 pixel
    Row 1 = 27pixel
    Row 2 = 92 pixel
    Row 3 = 26 pixel
    Row 4 = 3 Pixel


    Sub Set_label_page()
    '
    ' Setup page for label.
    '
    
        Columns("A:A").ColumnWidth = 22.14
        Columns("B:B").ColumnWidth = 22.14
        Columns("E:E").ColumnWidth = 22.14
        Columns("F:F").ColumnWidth = 22.14
        Columns("C:C").ColumnWidth = 3.29
        Columns("D:D").ColumnWidth = 3.29
        Rows("1:1").RowHeight = 20.25
        Rows("2:2").RowHeight = 69
        Rows("3:3").RowHeight = 20.25
        Rows("4:4").RowHeight = 2.25
        Range("A2:B2").Select
            Selection.Merge
        Range("E2:F2").Select
            Selection.Merge
            
    End Sub
    I want repeat the measurement of row 1 to 4 over and over until it get to row 450.

    Once the rows are set merge cells A2:B2 and then E2:F2 move down 4 rows merge A6:B6 and then E6:F6 and repeat untl row 450.

    Can someone show me how to repeat loop

    Please see the attached file. I ave created button which user presses to setup sheet.

    Help would be apricated.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Button macro to setup Columns And rows for sheet.

    I guess you could do it like this. By the way, merging cells is generally not advisable.
    Sub Set_label_page()
    '
    ' Setup page for label.
    '
    Dim r As Long
    
    Sheets("Sheet2").Select
    Columns("A:B").ColumnWidth = 22.14
    Columns("E:F").ColumnWidth = 22.14
    Columns("C:D").ColumnWidth = 3.29
    For r = 1 To 446 Step 4
        Rows(r).RowHeight = 20.25
        Rows(r + 1).RowHeight = 69
        Rows(r + 2).RowHeight = 20.25
        Rows(r + 3).RowHeight = 2.25
        Cells(r + 1, 1).Resize(, 2).Merge
        Cells(r + 1, 5).Resize(, 2).Merge
    Next r
    
    End Sub

+ 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