+ Reply to Thread
Results 1 to 7 of 7

VBA Formula for hiding/unhiding rows- Formula tweak

  1. #1
    Registered User
    Join Date
    10-27-2014
    Location
    UK
    MS-Off Ver
    7
    Posts
    43

    VBA Formula for hiding/unhiding rows- Formula tweak

    Hi All,

    I am using the below VBA code and its working fine if I want to hide the 2nd row to the 7th row below the target value, but if I want to use it to hide the 6th to the 10th row below that particular value, I am not able to. The code I am using is :

    Please Login or Register  to view this content.
    When I change the target.row+1 to target.row+5 it is not hiding the 5th, 6th and the 7th row, it hides only the target+5th row:

    Please Login or Register  to view this content.
    Please help!
    Last edited by varmoh; 02-19-2015 at 08:35 AM.

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

    Re: VBA Formula for hiding/unhiding rows- Formula tweak

    Line 6 looks like it could be a problem
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-27-2014
    Location
    UK
    MS-Off Ver
    7
    Posts
    43

    Re: VBA Formula for hiding/unhiding rows- Formula tweak

    Hi Davesexcel,

    Thank you for you response

    When I try using the below code, it does not give me the result I want
    for e.g., If I enter the value in row 10 of column C, I want rows 15 to 17 to hide..similarly, when I choose enter the value in any rows I want the 5th to 8th row below it to hide but the below formula is hiding only row 12.

    Please help!
    Please Login or Register  to view this content.

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

    Re: VBA Formula for hiding/unhiding rows- Formula tweak

    I thought pointing out the line would give you a hint.

    You have Rows(Target.Row + 4 & ":" & Target.Row + 2)
    if the target.row is 1 then
    target row+4 is 5
    target.row +2 is 3


    Look at your first code and see the difference.

  5. #5
    Registered User
    Join Date
    10-27-2014
    Location
    UK
    MS-Off Ver
    7
    Posts
    43

    Re: VBA Formula for hiding/unhiding rows- Formula tweak

    Sorry to sound stupid, I am using VBA for the first time!!!

    That works but only hides one row, if I mention Rows(Target.Row + 4 & ":" & Target.Row + 2) it hides only the target+4 i.e, the 5th row, I want the 6th and the 7th row to be hidden as well... Is that possible! or am I missing something?

    Thank you so much for your help and understanding!!

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

    Re: VBA Formula for hiding/unhiding rows- Formula tweak

    varmoh,

    Change the 2 to a 7



    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    10-27-2014
    Location
    UK
    MS-Off Ver
    7
    Posts
    43

    Re: VBA Formula for hiding/unhiding rows- Formula tweak

    It is finally working they way I want, Thank you !!!!!... and apologies for not being able to understand the first time!!!

+ 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. Hiding/Unhiding rows
    By cool53 in forum Excel General
    Replies: 8
    Last Post: 10-25-2013, 02:31 AM
  2. [SOLVED] Hiding and Unhiding Rows
    By jessmr in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-24-2013, 03:29 PM
  3. Hiding/Unhiding Rows
    By marcheese in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2012, 11:56 PM
  4. Hiding/Unhiding Columns referencing a cell with a formula
    By nabeel.pnm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-16-2012, 03:00 AM
  5. Hiding and unhiding rows
    By Ranjani in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-18-2009, 02:37 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