+ Reply to Thread
Results 1 to 14 of 14

Hide cells using an IF function

  1. #1
    Registered User
    Join Date
    12-10-2013
    Location
    Cambs
    MS-Off Ver
    Excel 2010
    Posts
    40

    Red face Hide cells using an IF function

    Good afternoon,

    I'm new to this forum and looking for some much needed assistance.

    I require to hide cells 30:54 on a spreadsheet should the value of cell D3 return either Saturday or Sunday.

    I've never run macros or used VB so go easy on me.


    Thanks in advance.

  2. #2
    Forum Contributor
    Join Date
    03-28-2013
    Location
    *
    MS-Off Ver
    Excel 2010
    Posts
    226

    Re: Hide cells using an IF function

    you mean like this?
    Please Login or Register  to view this content.
    Give Feedback and Click(*)

  3. #3
    Registered User
    Join Date
    12-10-2013
    Location
    Cambs
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Hide cells using an IF function

    Hello Venkatpvc,

    Thank you so much for your response.

    I tried it, but it doesnt seem to work automatically. for instance when I type in a date and it returns either a Saturday or Sunday the cells do not clear. It does however work when I run the macro.

    I presume I am doing something wrong.

    Sorry, new to Visual Basic and Macros.

  4. #4
    Forum Contributor
    Join Date
    03-28-2013
    Location
    *
    MS-Off Ver
    Excel 2010
    Posts
    226

    Re: Hide cells using an IF function

    ok
    Right Click on Sheet Tab Name and Click View Code and paste this below into that module.
    Please Login or Register  to view this content.

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526

    Re: Hide cells using an IF function

    Quote Originally Posted by a13ks View Post
    .....for instance when I type in a date and it returns either a Saturday or Sunday the cells do not clear......
    Do you want the cells to clear or rows to hide?

  6. #6
    Registered User
    Join Date
    12-10-2013
    Location
    Cambs
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Hide cells using an IF function

    Thank you so much for your help. I'm so sorry, but it still isnt working.

    Any ideas?

  7. #7
    Registered User
    Join Date
    12-10-2013
    Location
    Cambs
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Hide cells using an IF function

    Hi Davesexcel.

    Thanks for the response.

    Hide if possible.

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526

    Re: Hide cells using an IF function

    You can use a VBA IIF statement to hide or un-hide rows as well.
    Something like this in the worksheet module.
    Is Range("D3") being changed with a formula? if so we would have to use worksheet calculate I suppose.

    Here is the worksheet change code.

    Please Login or Register  to view this content.
    Attach a simple sample if you have to.

    More info on VBA IIF Statement.
    http://www.davesexcel.com/apps/blog/...atement-in-vba
    Last edited by davesexcel; 12-14-2013 at 10:43 AM.

  9. #9
    Registered User
    Join Date
    12-10-2013
    Location
    Cambs
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Hide cells using an IF function

    Here is a sample of the spread sheet. Hope it helps.

    Thank you so much for your help so far.
    Attached Files Attached Files

  10. #10
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526

    Re: Hide cells using an IF function

    Try this instead, it looks like D2 is the cell that will be manually entered on the worksheet.
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    12-10-2013
    Location
    Cambs
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Hide cells using an IF function

    I must be doing something wrong because I've entered that code but it just doesn't seem to hide them cells when the date calculates a Sat or Sun.

    I'm so sorry for my incompetance. ha ha

  12. #12
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526

    Re: Hide cells using an IF function

    It does work, when I change the date in D2 the rows hide and unhide.

    Signing off for now, going Christmas shopping!!!

  13. #13
    Registered User
    Join Date
    12-10-2013
    Location
    Cambs
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Hide cells using an IF function

    I finally got it to work!!!!

    Thanks for your help. Enjoy you xmas shopping.

    The only thing it doesn't do is hide the images/logos I have in the cells. Is there a way of hiding these at the same time?

  14. #14
    Forum Contributor
    Join Date
    10-01-2013
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    136

    Re: Hide cells using an IF function

    @ davesexcel: It is really nice to learn about the IIF function....this is actually my first time of doing it. But below is my code using only the "If" function and it works.

    Please Login or Register  to view this content.
    Last edited by vnzerem; 12-16-2013 at 10:25 PM.

+ 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. HIDE ZEROS IN CHART - Hide rows of cells that equals zero
    By sweedey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-09-2011, 08:18 PM
  2. Macro to format cells, adjust column widths, hide cells
    By amsolmyers in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2010, 04:44 PM
  3. Function to Hide Cells with No Value
    By cannisdill in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-15-2009, 07:04 PM
  4. [SOLVED] Want to show/hide cells depending on other cells results
    By Marco in forum Excel General
    Replies: 0
    Last Post: 08-15-2006, 01:25 PM
  5. show value but hide function
    By idanovich@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-26-2006, 03: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