Closed Thread
Results 1 to 12 of 12

How to make a cell a generic checkbox

  1. #1
    Registered User
    Join Date
    09-20-2006
    Posts
    6

    How to make a cell a generic checkbox

    I know I've seen it done before but I'm at a loss on how to do this:

    Without using the control toolbox, I want to format cells that will appear with an 'X' type of mark in them when clicked on by the mouse.

    I have a spreadsheet that has about 30 different choices for a given person; each person will have a different number of boxes checked and the easiest way for me to input the person's selections is to simply click my mouse on the appropriate boxes.

    Also, does anyone know how to make the active cell move to the right when pressing ENTER rather than down?

    Any input on this is much appreciated....

  2. #2
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    Could be feasible with an event macro ...
    Private Sub Worksheet_BeforeDoubleClick

    Is that what you are thinking about ?

    Cheers
    Carim

  3. #3
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097

    Thumbs up

    Hi Brightguy,

    Also, does anyone know how to make the active cell move to the right when pressing ENTER rather than down?

    Go to Tools > Options > Edit Move selection after enter and select direction

    oldchippy

  4. #4
    Registered User
    Join Date
    09-20-2006
    Posts
    6
    Thanks guys...

    1) I don't know how I missed the direction controlability under the options, but that does the trick

    2) As far as the event macros go - I'll be honest and I've screwed around with macros a little but I don't use Excel on a regular basis. So although I know how to generically record macros, I'm not complete sure how to create event macros using Visual Basic.

    Here's exactly what I'm looking for and I'm pretty sure there's a way to do it:

    When someclicks (or double clicks) on/in a cell I want an 'X' to appear (created in the way that you can edit the cell's borders and add the diagonal lines through the cell).

    Because I'm a bozo with Visual Basic I simply recorded a macro that put that 'X' into a cell. I'm wondering if I can edit that module so that it's activated by a single or double click on the cell.

    I'm going to try a few things and see if I can get it to work. If there's something simple I can do the additional direction is appreciated. None-the-less thanks for pointing me in the right direction.
    Last edited by brightguy; 09-20-2006 at 10:22 PM.

  5. #5
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by brightguy
    Thanks guys...

    1) I don't know how I missed the direction controlability under the options, but that does the trick

    2) As far as the event macros go - I'll be honest and I've screwed around with macros a little but I don't use Excel on a regular basis. So although I know how to generically record macros, I'm not complete sure how to create event macros using Visual Basic.

    Here's exactly what I'm looking for and I'm pretty sure there's a way to do it:

    When someclicks (or double clicks) on/in a cell I want an 'X' to appear (created in the way that you can edit the cell's borders and add the diagonal lines through the cell).

    Because I'm a bozo with Visual Basic I simply recorded a macro that put that 'X' into a cell. I'm wondering if I can edit that module so that it's activated by a single or double click on the cell.

    I'm going to try a few things and see if I can get it to work. If there's something simple I can do the additional direction is appreciated. None-the-less thanks for pointing me in the right direction.
    This is something that I picked up along the way, is this an idea along your path?

    ---
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    09-20-2006
    Posts
    6
    Bryan- thanks. I took a look at that macro but it's not the idea I'm looking for. I appreciate the help though.

    Ultimately, what I'm trying to create is like a shopping list. In column 1 there is a list of items that you can buy (i.e. celery, carrots, bread, milk) and each time you go shopping you can open the list and click onto the cell to the right of a particular item to indicate you need the item. When you click the cell to the right of an item, an 'X' (or other mark) appears there. In the end, you have a list of 100 grocery items but only the things you need have an 'X' in their adjacent column.

    I'm looking for the generic macro way to make a check box without using the ActiveX controls (which my simple mind finds tedious sometimes for larger projects).

  7. #7
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,953
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Target = "X"
    End Sub
    Ben Van Johnson

  8. #8
    Registered User
    Join Date
    09-20-2006
    Posts
    6
    thanks Ben... I copied and pasted that into VB, restarted and although the macro is running, it doesn't do anything. I double click on cells but nothing happens.

    Not sure what's up...

  9. #9
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by brightguy
    thanks Ben... I copied and pasted that into VB, restarted and although the macro is running, it doesn't do anything. I double click on cells but nothing happens.

    Not sure what's up...
    It worked for me, did you put it into the specific worksheet?

    ---

  10. #10
    Registered User
    Join Date
    09-20-2006
    Posts
    6
    I must be doing something wrong. Here's what I did to test it:

    1) opened a new workbook
    2) opened visual basic editor
    3) right clicked on "This workbook" at the left, selected "Insert - Module"
    4) copied and pasted in Ben's code above
    5) Exited the editor
    6) Saved workbook
    7) Closed workbook
    8) Opened the save workbook
    9) Warning came up - do I want to enable macros?
    10) I clicked YES and it opened
    11) I double click on a cell but nothing happens

    I even tried doing this, but instead right clicking on the specific worksheet and adding a module.

    I'm using Excel 2003 and I have no idea what I'm doing wrong
    Last edited by brightguy; 09-22-2006 at 10:40 PM.

  11. #11
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by brightguy
    I must be doing something wrong. Here's what I did to test it:

    1) opened a new workbook
    2) opened visual basic editor
    3) right clicked on "This workbook" at the left, selected "Insert - Module"
    4) copied and pasted in Ben's code above
    5) Exited the editor
    6) Saved workbook
    7) Closed workbook
    8) Opened the save workbook
    9) Warning came up - do I want to enable macros?
    10) I clicked YES and it opened
    11) I double click on a cell but nothing happens

    I even tried doing this, but instead right clicking on the specific worksheet and adding a module.

    I'm using Excel 2003 and I have no idea what I'm doing wrong
    What Ben gave you was
    Please Login or Register  to view this content.
    which says 'Private Worksheet', so it needs to go in the required Worksheet, not in the workbook or a module.
    ---

  12. #12
    Registered User
    Join Date
    09-20-2006
    Posts
    6
    Awesome Bryan....

    I got it to work now. Since I don't usually screw around with macros I had just assumed to create a module to put it in instead of viewing the worksheets code and putting it in there. Thanks guys...

Closed 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