+ Reply to Thread
Results 1 to 10 of 10

How to determine what Cell was selected

  1. #1
    Registered User
    Join Date
    07-09-2007
    Posts
    79

    Smile How to determine what Cell was selected

    Help needed,

    Can anyone help me in finding how to write the command in VBA to determine what Cell was selected in a worksheet? The objective is to know what Cell has been selected by double click event to pop up a userform with a calendar from which the user can select the date. I am looking at making it dynamic so I do not select a particular range.

    Can this be achieved? I guess yes, but how?

    Looking forward for your feedback.

    Appreciate your help.
    Last edited by chamdan; 11-02-2009 at 12:10 PM. Reason: Resolved

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to determine what Cell was selected

    See the Worksheet_BeforeDoubleClick event which passes the double-clicked cell as Range (Target).

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: How to determine what Cell was selected

    right click sheet tab and view code.
    paste the following

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Registered User
    Join Date
    07-09-2007
    Posts
    79

    Re: How to determine what Cell was selected

    Appreciate your prompt reply .

    I have tried this but it is not working. Is there something wrong?

    Please Login or Register  to view this content.
    Last edited by chamdan; 11-03-2009 at 08:50 AM. Reason: Rules infraction

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: How to determine what Cell was selected

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here


    Why are you trying to assign the target to a range reference?

    Just use the Target object

  6. #6
    Registered User
    Join Date
    07-09-2007
    Posts
    79

    Re: How to determine what Cell was selected

    Please Login or Register  to view this content.
    I tried this but did not work too. Sorry but I am not a VBA expert just a beginner.

    Would appreciate if you can provide me with the command line that would resolve my issue?

    Thanks for your tip.

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: How to determine what Cell was selected

    Please Login or Register  to view this content.
    You have not explained why you are doing this though.

    When userform1 shows what variable will it be trying to use?

  8. #8
    Registered User
    Join Date
    07-09-2007
    Posts
    79

    Thumbs up Re: How to determine what Cell was selected

    Thanks Andy,

    The objective is to select a date from the calendar and the date will be placed in the appropriate targeted cell.

    Please Login or Register  to view this content.
    This worked exactly the way I wanted.


    Cheers!

  9. #9
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: How to determine what Cell was selected

    this will cover teh calanda bit for you

    Go to Tools / Macro / VBE
    Go to Insert / UserForm from within the VBE.
    Open Control Toolbox, if not go to View / Toolbox etc
    Right click on the Toolbox and select Additional Controls
    Find Calendar Control 10.0 and check the checkbox and click OK
    Select the UserForm go to View / Properties Window
    Select Caption from the Properties Window and replace:
    UserForm1 with the word Calendar (This is critical)
    Go to View / Code add the code exactly as show below:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Go to Insert / Module and in a new module copy this code
    Please Login or Register  to view this content.

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to determine what Cell was selected

    Remember however that the Calendar control is not always available by default.

    chamdan, you have still not corrected your code tags from earlier (missing) - please edit your post accordingly.

    No further posts until actioned, thanks.

    D.O.

+ 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