+ Reply to Thread
Results 1 to 5 of 5

Row Selection Only & Deselect by Clicking Outside the Table.

  1. #1
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    112

    Question Row Selection Only & Deselect by Clicking Outside the Table.

    Is there a way to select an entire row only within a table BUT disable individual selection of cells, disable in cell editing, disable moving of cells AND THEN be able to click anywhere outside the table to deselect that row BUT must not select another cell when doing so?

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Row Selection Only & Deselect by Clicking Outside the Table.

    You'll need to use VBA. Right click the sheet name, select "View Code" and paste this:

    Please Login or Register  to view this content.
    Change the "tblPolicies" to whatever the name of your table is (assuming it's an Excel table).

    WBD
    Office 365 on Windows 11, looking for rep!

  3. #3
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    112

    Re: Row Selection Only & Deselect by Clicking Outside the Table.

    Hi! Thank you... Had to amend slightly, but how do I get it so that I can click anywhere outside the table and it deselects (As opposed to selecting a new cell).

    Also my 1st column is allowing editing if I double click? can that be locked as well?

    My code looks like this:
    Please Login or Register  to view this content.

  4. #4
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Row Selection Only & Deselect by Clicking Outside the Table.

    This is Excel; some cell on the sheet is always selected - the cursor has to be positioned *somewhere*. The best you could do, maybe, is to hide a column and change the selected cell to be there. Or perhaps set the selection to be somewhere off screen. I noticed you removed the disabling/re-enabling of the events - just be careful you don't end up in a loop as you're changing the selection in the changing a selection code. You also hard-coded the FAC_RISKS name so you can remove the Const declaration. Here's something that will select the cell to the right of the header row if you don't select in the table and it will also prevent double-click from activating a cell edit:

    Please Login or Register  to view this content.
    WBD

  5. #5
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    112

    Re: Row Selection Only & Deselect by Clicking Outside the Table.

    I added the event procedures again to the 1st and it worked perfectly.

    Thank you!

+ 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. Deselect selection if it's not within a defined range
    By Shanthan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-31-2013, 11:10 AM
  2. Select/Deselect All in Pivot table row
    By j-dawg in forum Excel General
    Replies: 1
    Last Post: 02-25-2009, 11:25 AM
  3. Deselect All in a Pivot Table
    By jpx in forum Excel General
    Replies: 1
    Last Post: 05-02-2006, 01:55 PM
  4. Deselect cells with formulas in selection
    By Thorsten Gleumes in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-02-2006, 11:10 AM
  5. programmatically deselect a selection?
    By Rich in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-24-2006, 07:35 PM
  6. deselect from a non-contiguous selection?
    By me in forum Excel General
    Replies: 4
    Last Post: 11-15-2005, 03:30 PM
  7. Pivot Table Deselect all items
    By Keyur in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-06-2005, 02:06 PM

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