Results 1 to 1 of 1

Can someone help me add code to macro so it only formats visible rows in a set range?

Threaded View

mltornroth Can someone help me add code... 06-19-2012, 03:40 AM
  1. #1
    Registered User
    Join Date
    05-29-2012
    Location
    San Diego, CA USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Can someone help me add code to macro so it only formats visible rows in a set range?

    I have a form I've created in Excel that includes a section where several rows have been hidden from view. If the user requires additional rows to be added, I have inserted a button to unhide rows one at a time. All of that works wonderfully. However, since many of my fields are comprised of merged cell ranges, I've implemented (an admittedly over-complicated) way to wrap/fit text in those ranges. The code applies the desired formatting to the rows that I've defined as appropriate and skips over the occassional row. So ultimately the macro applies the formatting to a range of rows but passes over a select few. When I run it though, it actually unhides all rows hidden and I am left with my excel pants down so to speak. If anyone can advise I would be so grateful. Thanks in advance

    Code to Fit Text:

    Private Sub CommandButton1_Click()
    Sub FitText1()
    '
    ' FitText1 Macro
    '
    ' Keyboard Shortcut: Ctrl+t
    '
        ActiveWindow.DisplayHeadings = True
        Rows("46:63").Select
        Selection.Rows.AutoFit
        Rows("67:69").Select
        Selection.Rows.AutoFit
        Rows("81:84").Select
        Selection.Rows.AutoFit
        ActiveWindow.DisplayHeadings = False
        Range("B46:K46").Select
        ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
            , AllowFormattingCells:=True, AllowFormattingColumns:=True, _
            AllowFormattingRows:=True, AllowInsertingRows:=True, AllowDeletingRows:= _
            True
    End Sub
    Astellas AE Form.xls
    Last edited by Leith Ross; 06-19-2012 at 04:01 AM. Reason: Added Code Tags

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