+ Reply to Thread
Results 1 to 6 of 6

Hiding Rows based on the value in column A, starting at row 9

  1. #1
    Registered User
    Join Date
    05-06-2015
    Location
    Wales
    MS-Off Ver
    2010
    Posts
    13

    Hiding Rows based on the value in column A, starting at row 9

    Hi, so i am trying to create a macro which will hide a row if the value in the first column says "REMOVE" for the row in question, this is my code so far

    Please Login or Register  to view this content.
    The first part unhides everything then hides the rows with the word "REMOVE" in the first column. It is currently not working, any help would be great. Note, i need to run this to the last empty row. When i try to run this i get the "compile error, argument not optional"



    Another question, i also need a separate macro assigned to different keys to unhide all cells, regardless of value

    Thank you in advance.
    Last edited by craig159753; 05-15-2015 at 10:29 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Hiding Rows based on the value in column A, starting at row 9

    4 things:
    1. It will use the value "DELETE" not "REMOVE"
    2. You shouldn't call Worksheet_Change. Worksheet_Change is meant to activate whenever the worksheet is changed. If you want that, then you don't need the other sub. If you want to activate it manually, then it should be in a normal sub and probably in a normal code module.
    3. You shouldn't need to SELECT anything. Selecting is only needed for the user, but VBA can operate on any cells without selecting them first.
    4. You have no loop or filter. This code currently only checks the value of A9 and will ignore all values in A10, A11, etc. If you want it to check those values, you'll need to use a loop or filter.
    1. Include a sample workbook with an example of the result you want
    2. Use [CODE] and [FORMULA] wrappers for your VBA code or excel formulas
    3. If your question has been answered, mark the thread as SOLVED and click on the "Add Rep" star to thank whoever helped you.

  3. #3
    Registered User
    Join Date
    05-06-2015
    Location
    Wales
    MS-Off Ver
    2010
    Posts
    13

    Re: Hiding Rows based on the value in column A, starting at row 9

    So i updated my code, two macros one hides rows based on a value, ne shows all rows


    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Hiding Rows based on the value in column A, starting at row 9

    Great, does that solve your issue? Or is there something else you wanted it to do? To selectively hide rows, just put an if statement in the loop.

  5. #5
    Registered User
    Join Date
    05-06-2015
    Location
    Wales
    MS-Off Ver
    2010
    Posts
    13

    Re: Hiding Rows based on the value in column A, starting at row 9

    I further changed it to this, however it isnt working. And i cant seem to assign keyboard shortcuts to the show_rows macro :S

    New code


    Please Login or Register  to view this content.
    I get the error, "run time error '13' Type Mismatch"

  6. #6
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Hiding Rows based on the value in column A, starting at row 9

    Try changing "ThisWorkbook.Worksheets(Sheets("AE").Rows(i)).EntireRow.Hidden = True" to "ThisWorkbook.Sheets("AE").Rows(i).EntireRow.Hidden = True"

    To assign a shortcut, go to Macros, select your macro, and click Options.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Help with hiding rows based on Column D values
    By Ellen 2Excel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-15-2014, 01:58 PM
  2. Un-Hiding and Hiding Columns based on Drop-Down Values in a Column.
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2011, 06:49 AM
  3. [SOLVED] Hiding rows based on a column value
    By Mark Hansen in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-09-2006, 01:40 PM
  4. Hiding Rows in a Range based on column A value
    By tig in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-09-2006, 01:10 PM
  5. Hiding column/row labels --without hiding entire columns/rows
    By daniel.wolff@csfb.com in forum Excel General
    Replies: 2
    Last Post: 10-18-2005, 10:05 PM

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