+ Reply to Thread
Results 1 to 3 of 3

Macro to hide a particular row and particular column based on a formula

  1. #1
    Registered User
    Join Date
    05-29-2011
    Location
    Edinburgh
    MS-Off Ver
    Office365
    Posts
    46

    Macro to hide a particular row and particular column based on a formula

    I have been developing my excel macro skills in recent weeks, but still don't know how to write code in VBA,so anything unusual that can't be done by recording a macro still eludes me...

    I need to write a macro that hides ONE row and ONE column from a workbook

    Problem is the exact row and column that require hiding will vary from time to time depending on the results of other formulae.

    I have successfully written a formula using ADDRESS and MATCH that works out which row and column need hiding, and stores the result in S6 (i.e. cell S6 currently contains the text "$D$9" indicating that the row and column that contain cell D9 are the row and column that currently require to be hidden. However on a different day, it could be E10 or F4 etc instead)

    How can I write code to tell the worksheet to hide column D and row 9, whilst using the value in S6 to check which row and column to hide.

    Also, to make things a tiny bit more complicated, I only need to hide these rows if cell P7 contains the value FALSE. If cell P7 is true, then I don't need to hide anything at all...


    Thanks in advance. Am happy to re-explain if anything isn't clear
    Last edited by Smeddlesboy; 05-29-2011 at 06:55 AM.

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Macro to hide a particular row and particular column based on a formula

    hi, please check attachment, run code "test"
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    05-29-2011
    Location
    Edinburgh
    MS-Off Ver
    Office365
    Posts
    46

    Re: Macro to hide a particular row and particular column based on a formula

    Perfect, thank you - and so simple too!

    As a complete novice, I hadn't realised about using square brackets to specify a particular reference - now I know that I can probably put it to very good use!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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