+ Reply to Thread
Results 1 to 11 of 11

Getting mouse selected cell as input to start operations on data of that cell row

  1. #1
    Registered User
    Join Date
    09-09-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    35

    Getting mouse selected cell as input to start operations on data of that cell row

    Hi all,

    This is what I am trying to do:

    1) Launch macro
    2) macro will prompt me to select a cell
    3) I will use my mouse to click on the cell within a table
    4) macro will then use the row value of that cell to grab data off the whole row
    5) using the data I will populate another sheet

    Problem is step 3. How do I get an input from cell selection?

  2. #2
    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: Getting mouse selected cell as input to start operations on data of that cell row

    Hello reach78,

    Clicking a cell makes it the ActiveCell. You can use the Row property to obtain the row of cell.
    Please Login or Register  to view this content.
    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!)

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Getting mouse selected cell as input to start operations on data of that cell row

    Use Application.inputbox with the Type argument set to 8 to return a Range object.
    Remember what the dormouse said
    Feed your head

  4. #4
    Registered User
    Join Date
    09-09-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Getting mouse selected cell as input to start operations on data of that cell row

    Hi All,

    Thanks for the input so far. I managed to get the thing going but am having trouble trying to get the row value from the range object once I selected the row I wanna use. Here's the code I have generated

    Please Login or Register  to view this content.
    How do I get the row value so I can select a range within that selected row? I'm trying to copy from column 2 to column 7 within that row

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Getting mouse selected cell as input to start operations on data of that cell row

    It's just row.row (not a good name for a variable!) instead of Range(Row).Row

  6. #6
    Registered User
    Join Date
    09-09-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Getting mouse selected cell as input to start operations on data of that cell row

    The code below now works:

    Please Login or Register  to view this content.
    However when I replace:

    Please Login or Register  to view this content.
    To call a specific cell and paste it to a specific location in another sheet. It breaks down. The code I replaced it with is

    Please Login or Register  to view this content.
    The debugger hangs at the Select.PasteSpecial... line. Code somewhere above it wrong I guess?
    Last edited by reach78; 09-19-2013 at 07:44 PM.

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Getting mouse selected cell as input to start operations on data of that cell row

    You're still using Set row =

  8. #8
    Registered User
    Join Date
    09-09-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Getting mouse selected cell as input to start operations on data of that cell row

    Hi romperstomper,

    Nope, I've changed it before to a new variable name following your suggestion

    I tried the macro with a paste on the same worksheet it works fine. But if I try to paste it to a specific cell in another worksheet, then it all goes wrong. I think it has to do with how I am calling out the other sheet. I'm still new to VBA so am shaky when it comes to semantics/syntax/knowing the vba objects etc

  9. #9
    Registered User
    Join Date
    09-09-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Getting mouse selected cell as input to start operations on data of that cell row

    Attached screenshot showing the error line--> error.jpg

  10. #10
    Registered User
    Join Date
    09-09-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Getting mouse selected cell as input to start operations on data of that cell row

    Nevermind, I feel so stupid...

    I was trying to paste to a 'merged' cell. I unmerged it. Ran the macro....and it works...Doh!

  11. #11
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Getting mouse selected cell as input to start operations on data of that cell row

    As that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED,as per Forum Rule #9. Thank you.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

+ 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. [SOLVED] Automatically input data into cell D1 whenever criteria selected
    By chisox721 in forum Excel General
    Replies: 9
    Last Post: 08-23-2013, 07:55 AM
  2. Mouse/Curser drags when cell selected
    By LGR in forum Excel General
    Replies: 1
    Last Post: 10-15-2011, 01:41 PM
  3. Start macro on cell input
    By CJ-22 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-10-2006, 02:17 AM
  4. Macro to start when cell selected
    By JackR in forum Excel General
    Replies: 8
    Last Post: 03-20-2006, 12:10 PM
  5. Replies: 1
    Last Post: 08-12-2005, 08:05 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