+ Reply to Thread
Results 1 to 9 of 9

Macro Checkbox to hide multiple blank rows

  1. #1
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Indonesia
    MS-Off Ver
    2010
    Posts
    177

    Macro Checkbox to hide multiple blank rows

    Greeting,

    i find this forum from google, i saw many good knowledge to learn here,
    i am very newbie in VBA stuff.
    Maybe this question already answered somewhere in the forum, but i can't figured out.

    My question maybe very basic to you all.
    i want to learn about how to use macro checkbox.
    basically i want to create checkbox1 in column B when clicked ( True) then it will hide blank cells in rows, and cells with "X" will show
    then in column C, when clicked then will hide blank cells in rows, and cells "X" will show.
    note: if no checkbox click, then all cells will unhide.

    to be more clearly, please check attached excel file. ( still no macro on it).

    appreciate if someone can assist me.
    thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro Checkbox to hide multiple blank rows

    Hello qiyusi,

    Welcome to the Forum!

    The macro below has been added to the attached workbook. The rectangles have been replaced with Forms Control CheckBoxes and the macro assigned to them.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Indonesia
    MS-Off Ver
    2010
    Posts
    177

    Re: Macro Checkbox to hide multiple blank rows

    Wonderful! Works perfectly!

    Many thanks for your help master. really appreciate it.

    wondering to know the language,

    1. dim c ---> c refer to what? is it column C? if i insert another two checkbox c change to e?


    2. ' CurrentRegion is the cells in the table.
    Set Rng = Range("A1").CurrentRegion
    if i insert two column to the right, so the range cells begin in C1, then Range("A1") should be change to Range("C1") ?

    3. ' Ignore the first 2 rows of the table.
    Set Rng = Intersect(Rng, Rng.Offset(2, 0)) --- > if i insert two column to the right as question no.2 should this rng.offset change?

    sorry to ask dumb question, i am really beginner at this point.
    Last edited by qiyusi; 10-22-2014 at 10:36 PM. Reason: additional question

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro Checkbox to hide multiple blank rows

    Hello qiyusi,

    Not dumb questions at all.

    The variable "c" is a long data type used to hold the column number.

    The current region is defined as a range of contiguous (touching) cells. The boundaries are one or more blank rows or columns or the edge of the worksheet.

    The First 2 rows are just header data. This does not need to be checked.

  5. #5
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Indonesia
    MS-Off Ver
    2010
    Posts
    177

    Re: Macro Checkbox to hide multiple blank rows

    thanks for prompt reply,

    i try to insert one column so the tables start from B1, the macro still ok.

    then i try to insert another one column, so the tables start from C1, it give error message "Object Variable with Block Variable not set"

    what should i change?

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro Checkbox to hide multiple blank rows

    Hello qiyusi,

    The first cell of range is always the top leftmost cell. In the orinal table this was "A1". Now that you have moved the table by inserting new columns, the starting cell is "C1".

    This line needs to be changed...
    Please Login or Register  to view this content.

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro Checkbox to hide multiple blank rows

    Hello qiyusi,

    Okay, I revised the macro so you can move the table around. The check box names are now used to indicate the table column to use.

    Before I was using the worksheet column position which is absolute reference. Now, the check box name indicates a relative reference based on the table's columns.

    Please Login or Register  to view this content.
    Last edited by Leith Ross; 10-22-2014 at 11:19 PM.

  8. #8
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Indonesia
    MS-Off Ver
    2010
    Posts
    177

    Re: Macro Checkbox to hide multiple blank rows

    Brilliant!

    thank you very much for your help.

    i think the case solved.

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro Checkbox to hide multiple blank rows

    Hello qiyusi,,

    You're welcome. Glad to help.

+ 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] Macro needed to hide rows within multiple ranges if the cell value in each row is blank
    By TomP1988 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-21-2014, 11:04 AM
  2. Adding and Deleting Rows with a Hide Row Macro CheckBox
    By jason68691 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-18-2014, 04:23 PM
  3. [SOLVED] Macro to hide/unhide rows using more than one checkbox
    By tsou in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-29-2013, 08:37 AM
  4. Macro to hide/unhide rows using checkbox
    By jdp554 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-23-2011, 11:57 AM

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