+ Reply to Thread
Results 1 to 12 of 12

Trying to get an X to appear in cell when selected

  1. #1
    Registered User
    Join Date
    02-21-2008
    Posts
    8

    Smile Trying to get an X to appear in cell when selected

    I am trying to restrict a cell so all that happens when clicked is an X to appear in that cell. I'm new to this so the simpler the better. Thanks!!

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    Hi slimjim,

    Do you want ANY cell that is clicked to show an X, or just certain cells?

  3. #3
    Registered User
    Join Date
    02-21-2008
    Posts
    8
    I guess certain cells, but it is the majority of the worksheet. So far only column A and Row 1 have content in them and I think the rest can be made so that only an X appears when selected(and disappear when selected again). I'm basically trying to make a check list.

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    Ok. The following code, pasted into the worksheet's code module, will add or remove an X from a cell when you double-click on it. If you really want just a single-click we could use the Worksheet_SelectionChange event, however that gets triggered every time your cell selection changes (using mouse, arrows, tab, enter, etc.) and you could start adding X's all over the place if you're not careful.
    Please Login or Register  to view this content.
    This will add or remove an X from any cell when double-clicked as long as it's not in column A or row 1. (B2:IV65536 is fair game).

    Update: Added 'Cancel = True' so that the cell is deactivated after double-clicking, leaving just the X or blank (taking you out of cell edit mode).
    Last edited by Paul; 02-21-2008 at 01:18 AM.

  5. #5
    Registered User
    Join Date
    02-21-2008
    Posts
    8
    When you say code module do you mean Macros?

  6. #6
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    Yep.

    1. Right-click on the sheet tab for which you want to add this code. e.g. If you want this code to run on 'Sheet1', right-click on that tab then select 'View Code'.

    2. In the VB Editor window that appears, paste the code I provided into the right-hand window

    3. Close the VB Editor window

    4. Double-click any cell in row 2 or below, or column B and to the right.

  7. #7
    Registered User
    Join Date
    02-21-2008
    Posts
    8

    Unhappy

    Paul,
    I appreciate all your help on this, but it doesn't look like its working. It looks like the code is recognized cause it has Blue text(I copied it funky the first time and it was all red) but when I double click a cell it just gives me the option to type in it.

  8. #8
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    Can you zip and upload a copy of your workbook to the thread? I can take a look at it for you then.

  9. #9
    Registered User
    Join Date
    02-21-2008
    Posts
    8
    Again, thanks for your help. Your Avatar is exactly how I feel btw. =)
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    02-21-2008
    Posts
    8
    Ok thats wierd I just tried copying and pasting again and now it works....

  11. #11
    Registered User
    Join Date
    02-21-2008
    Posts
    8
    Yes!!

    It works for sure. I opened a new workbook and created the same checklist and pasted your code. I must have done something wierd on the first workbook when I was searching through all the functions and stuff to try to figure this out. Thanks for putting up with this excel noob!

  12. #12
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    Glad you got it working now. It's my pleasure to help when I can.

+ 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