+ Reply to Thread
Results 1 to 3 of 3

toggle with macro to hide/unhide entire row with cell that contains specific text

  1. #1
    Registered User
    Join Date
    04-19-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    49

    toggle with macro to hide/unhide entire row with cell that contains specific text

    Hi,

    My macro knowledge is limited. I'm hoping if I can explain what I need someone here may be able to write a simple macro instead of me spending hours trying to figure it out =).

    In this spreadsheet I've built, I have the entire 1040 tax code & form + several schedules (A,C, SE, Social Security Tax, AMT etc.). It's all tied to other sheets in the workbook for a financial projection. Within this specific "tax" worksheet I have two scenarios, [Base] and [Optimized]. They are shown one row above the other for every input or referenced cell.

    Line 1 Wages [Base]
    Line 1 Wages [Optimized]
    Line 2 Interest [Base]
    Line 2 Interest [Optimized]

    This continues for about 400 rows. I'm basically trying to hide/unhide every row for [Base] with the click/unclick of a button.

    Does that make sense?

    For a couple of other sheets within the workbook I went through and selected all the [Base] rows and named a range. Then I wrote this macro.

    Private Sub ToggleButton1_Click()

    If ToggleButton1.Value = True Then
    Range("Playground_Base").Select
    Selection.EntireRow.Hidden = True

    Else
    Cells.Select
    Selection.EntireRow.Hidden = False

    End If

    End Sub

    It works fine but it seems like it's looping and slow. I tried to use the same thing for this "tax" sheet but for some reason when I'm selecting rows for the range it always just unselects everything after about row 173. Not sure if it's my mouse, I'm retarded or there's a max I can select for the range??? I even tried selecting everything then choosing to define a name but after I save and select the range it's now every line between 1 and 173, not just the ones I individually picked with [Base] thru line 442. Anyway I thought there might be a better way period.

    Thanks! Let me know if there's anything I can do to provide a better picture.

    Brian

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: toggle with macro to hide/unhide entire row with cell that contains specific text

    HI,

    did you try using the autofilter on the Base/Optimized column?
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  3. #3
    Registered User
    Join Date
    04-19-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    49

    Re: toggle with macro to hide/unhide entire row with cell that contains specific text

    yes but it sorts them. if it left them in the current order that would work

+ 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