+ Reply to Thread
Results 1 to 20 of 20

I need to select a range on a cell click

  1. #1
    Registered User
    Join Date
    02-06-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2010
    Posts
    14

    I need to select a range on a cell click

    Hi. Someone I work for created a protected form and wanted the cells to be filled in in a specific order. I did this by creating a named range that is automatically highlighted when the workbook is opened. It works fine as long as the user just types in data and clicks tab or enter, but if the user clicks a cell, the range is no longer highlighted and the tab order goes back to default. I need some code that will select the range again if the user clicks any of the cells. The code I've used so far is below. I'm using Excel 2010 with the 64 bit version of Office. Thanks for any help you can give.

    Option Explicit

    Private Sub Workbook_Open()
    Range("Fill_Order_2").Select
    End Sub
    Attached Files Attached Files

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: I need to select a range on a cell click

    What range is fill_order_2?
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Registered User
    Join Date
    02-06-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: I need to select a range on a cell click

    It is the unlocked cells that he wants the user to fill in, chosen in the order he wants them filled in. The default order would be from top left to right to bottom left to right (a1, b1, c1, a2, b2, c2, etc.), but he wants the top part first, then the left side of the sheet, then the right side. I attached the file to the original post if anyone needed to see it to figure it out. Thanks.

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: I need to select a range on a cell click

    Maybe
    Please Login or Register  to view this content.
    e/ Place it in the Sheet1 module

  5. #5
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: I need to select a range on a cell click

    I forgot to add you'll probably want to change your previous code to
    Please Login or Register  to view this content.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: I need to select a range on a cell click

    Hello countingbackwards,

    Welcome to the Forum!

    All you need to do is unprotect the worksheet and reapply the protection. But this time be sure the check box "Select locked cells" is NOT CHECKED in the "Allow all users of the worksheet to:" list.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  7. #7
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: I need to select a range on a cell click

    I was under the impression that the order they were changed in was supposed to be a set pattern. However, after Leith's post I realized I had put Worksheet_Change instead of Worksheet_SelectionChange. Below is ammended.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    02-06-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: I need to select a range on a cell click

    The order is what is important, so Leith's answer won't work. Even when it is locked so other cells can't be selected, but selecting any cell makes the order go back to default instead of what I chose in my named range. As long as the range stays selected, the entries go in the order I want.

    I tried the code and it turns off the range going from cell to cell and makes it go in an odd order different from the order of the code or how I set up my range.

    Do you know if there is a code to initiate an event on a click? If so, I could use that like I use the code to select the range on open.

    Thanks to both of you for trying.

  9. #9
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: I need to select a range on a cell click

    The code is the same order you set your named range. I used your example sheet to find it. It can be changed, but I used
    Please Login or Register  to view this content.
    to find exactly what range you wanted.

  10. #10
    Registered User
    Join Date
    02-06-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: I need to select a range on a cell click

    Yeah I know...I checked the order. Instead of doing what it should, it basically just goes straight down the first column and then goes to the second. I'm looking around still for something that will select the range if a cell is clicked unless I can get your way to work somehow.

  11. #11
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: I need to select a range on a cell click

    In that manner, if they fill in part of the data and then click else where, re-selecting the range will force them to the first range they edited. Not, the first empty cell.

    I hope that made sense.

  12. #12
    Registered User
    Join Date
    02-06-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: I need to select a range on a cell click

    That would be true, but it would still preserve the order, and that is what the guy is going for. Going to the first empty cell would be fine with me, but before I can do that I have to get the range re-selected if they click instead of using tab or enter.

  13. #13
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: I need to select a range on a cell click

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    02-06-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: I need to select a range on a cell click

    wow...that isn't working either and I was sure it would. I've tried some variations like using the range name and using Application.Goto with it and it still won't re-select the range. It acts like nothing is happening at all and even with protection on after I click in a cell it is letting me click in locked cells. I think I'm about to give up on it for a while and see if something comes to me while I'm not thinking about it. Thanks for trying to help.

  15. #15
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: I need to select a range on a cell click

    Are you sure you've placed the code in the proper module?

  16. #16
    Registered User
    Join Date
    02-06-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: I need to select a range on a cell click

    no I'm not. I've tried using a new module and also putting it under my code for opening with the range selected. Where should I put it?

  17. #17
    Registered User
    Join Date
    02-06-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: I need to select a range on a cell click

    ok...got somewhere this time...when I put it in code for sheet1 it works to re-highlight the cells. I'll try the first code there to see if it works. I'll let you know. Thanks for all your help!
    Last edited by countingbackwards; 10-25-2013 at 04:51 PM.

  18. #18
    Registered User
    Join Date
    02-06-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: I need to select a range on a cell click

    ok...i used the <> code you suggested earlier directly in the sheet1 code. It keeps the order, but obviously doesn't allow blank cells, and it skips over the cells that have 0 in them by default because they <> "". If you have any thoughts on fixing that, please let me know. thanks again. have a great weekend!

  19. #19
    Registered User
    Join Date
    02-06-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: I need to select a range on a cell click

    Please Login or Register  to view this content.
    ...so this one forces entry into all the cells and skips the cells automatically set to 0 until all the others are filled. He doesn't necessarily need ALL the cells filled and will sometimes need the 0 values changed to something else, so is there a way to make it so that if the user just presses tab or enter it will go to the next cell in the list...basically instead of checking to see if the cell ="", check to see if the user pressed Enter or Tab...
    If not, this code
    Please Login or Register  to view this content.
    could work if there were a way to record the last position where something was entered, re-highlight the range, and start from that point. Another problem with having the whole thing selected is that if the user clicks delete to remove his/her previous entry, it deletes everything, so this is probably not the best method. Any ideas on that?

    I was thinking maybe if I set a name for the selection it could work, but that then changes the selection for the range to the cell selection.

    Sorry for being so ignorant about what should seem simple. I am new to writing from scratch. I usually record macros and modify the code to match what I need to happen. Thanks.
    Last edited by countingbackwards; 10-28-2013 at 12:17 PM.

  20. #20
    Registered User
    Join Date
    02-06-2013
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: I need to select a range on a cell click

    Now I'm using this:
    Please Login or Register  to view this content.
    At first it worked, but then I unprotected the sheet to correct a spelling error and when I protected the sheet again, it started going in the wrong order like the first one on Friday did where it went down the first part of the first column, then instead of going to the right part on the top, it went to the right part on the bottom and then just kind of randomly afterwards. It doesn't make sense because the order is listed and hasn't changed.

+ 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. Replies: 0
    Last Post: 10-21-2013, 02:14 PM
  2. [SOLVED] Select the cell with the click of a mouse, and have the result of calculation
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-03-2012, 06:26 AM
  3. Select something on click and paste in a new cell
    By Cata_bRc in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-29-2010, 09:59 AM
  4. Click to select cell under drawing object
    By tschroeder250 in forum Excel General
    Replies: 2
    Last Post: 06-26-2007, 10:50 PM
  5. [SOLVED] How do you control scroll rate when click and drag to select cell
    By rbperrie in forum Excel General
    Replies: 1
    Last Post: 06-25-2005, 05:05 AM

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