+ Reply to Thread
Results 1 to 5 of 5

Disabling columns based on the answer in another cell

  1. #1
    Registered User
    Join Date
    04-08-2015
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    2

    Disabling columns based on the answer in another cell

    Hi, I am new to excel programming etc

    I have one column with 3 answer options. Colonoscopy, Endoscopy, Combined endoscopy and colonoscopy
    If C is selected I want to block out columns relating to the other two options (further on in the worksheet).


    Specifically if

    Colonoscopy is selected in column D, I want to disable columns L-R (for that row)
    If Endoscopy is selected in column D (for a particular cell) , I want to disable columns S-Y (for that row)
    And if Combined is selected I want all columns available.

    If I could lock them and black them out/grey them out so that its clear that a response is not required it would be great.

    Is this possible?

    Thank you

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,859

    Re: Disabling columns based on the answer in another cell

    Give this a try:

    Please Login or Register  to view this content.
    How to install your new code
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Press Alt+F11 to open the Visual Basic Editor
    Choose Insert > Module
    Edit > Paste the macro into the module that appeared
    Close the VBEditor
    Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    Press Alt-F8 to open the macro list
    Select a macro in the list
    Click the Run button
    Last edited by alansidman; 04-08-2015 at 04:15 AM.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    12-11-2010
    Location
    Indiana, USA
    MS-Off Ver
    Excel 2007
    Posts
    118

    Re: Disabling columns based on the answer in another cell

    Not knowing how your sheet is set up, and if and where you can place any formulae I have just created a couple of scenarios.
    There is one solution on sheet1, and another on sheet2.
    Perhaps you can post a sample of your workbook for any further assistance.

    (edited)
    I just seen you have received an answer, but I can't seem to delete this reply.
    Attached Files Attached Files
    Last edited by ufopilot; 04-08-2015 at 04:45 AM.

  4. #4
    Registered User
    Join Date
    04-08-2015
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    2

    Re: Disabling columns based on the answer in another cell

    Hi

    Thank you for your help. I did try the code above but cannot see that anything happened.
    (Mind you , I have had to change the column letters due to a changed spreadsheet).

    I have attached a copy of my spreadsheet as the other poster asked. Ideally, I want it so that if someone selects ''colonoscopy'' in column D then only those columns with the heading Colonoscopy are available to enter data in, the others are greyed out.

    I really appreciate your help.
    Attached Files Attached Files

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,859

    Re: Disabling columns based on the answer in another cell

    See attached. Change the color code in the VBA as you desire using this page as a source of information

    http://dmcritchie.mvps.org/excel/colors.htm

    FYI: 15 is grey
    Attached Files Attached Files
    Last edited by alansidman; 04-08-2015 at 11:03 AM.

+ 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. answer based on cell value
    By robert.begley1 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 07-08-2014, 09:07 AM
  2. Enabling/Disabling Form Checkboxes based on value in a cell
    By HangMan in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-02-2014, 11:47 AM
  3. Replies: 2
    Last Post: 06-21-2013, 10:04 AM
  4. [SOLVED] Disabling UserForm fields based on Answer in another Value - VBA Excel 2012
    By eemiller1997 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-21-2012, 02:41 PM
  5. return answer based on cell value
    By excellentexcel in forum Excel General
    Replies: 2
    Last Post: 08-29-2009, 04:55 AM

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