+ Reply to Thread
Results 1 to 11 of 11

How to copy the value of a cell I click to the current active cell

  1. #1
    Registered User
    Join Date
    08-08-2014
    Location
    Orlando, Florida
    MS-Off Ver
    2010
    Posts
    10

    How to copy the value of a cell I click to the current active cell

    Looking to create an Employee schedule template that will allow the user to select shifts at the top of the excel sheet, that will intern automatically populate the active cell with the chosen (clicked on) shift.

    Example:
    If I am currently in cell C24, then click on the schedule shift of '8AM-6PM' in cell A1, the shift of '8AM-6PM' will copy to cell C24.

    Not sure if I need to use/create BUTTONS or if this can be accomplished another way. And if I need to use BUTTONS, how would I achieve this functionality?

    Any help is greatly appreciated.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How to copy the value of a cell I click to the current active cell

    Use a sheet specific macro.

    Probably the best option is to use the right click event.

    Ok.

    You need three macros to achieve this.

    An auto open macro

    and two sheet specific macros.
    right click on the sheet name at the bottom of excel and select view code to ammend the sheet specific macros.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    08-08-2014
    Location
    Orlando, Florida
    MS-Off Ver
    2010
    Posts
    10

    Re: How to copy the value of a cell I click to the current active cell

    @mehmetcik,
    Can't thank you enough for taking the time to respond with a Solution. I wish I understood the code, so I could better plan out the entire sheet. I'll play with the sheet a bit more and see if it works for my purpose as-is. I'll let you now! Again, thank you very much!

  4. #4
    Registered User
    Join Date
    08-08-2014
    Location
    Orlando, Florida
    MS-Off Ver
    2010
    Posts
    10

    Re: How to copy the value of a cell I click to the current active cell

    Can I assume "Target.Cells" are the cells where I would list the schedule shifts I need?

    Target.Cells.Count > 1
    Or Target.Cells.Row > 1 (Is this Row 1?)
    Or Target.Cells.Column > 3 (is this Column C?)
    Then GoTo 200 (What is this?)

    Example:
    Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    If Target.Cells.Count > 1 Or Target.Cells.Row > 1 Or Target.Cells.Column > 3 Then GoTo 200
    Range(LastCell).Value = Target.Value
    200 Cancel = True
    End Sub

  5. #5
    Registered User
    Join Date
    08-08-2014
    Location
    Orlando, Florida
    MS-Off Ver
    2010
    Posts
    10

    Re: How to copy the value of a cell I click to the current active cell

    Another question...

    Can I use something other than RightClick? I seem to use the Right click for a lot of other functions, and I'd hate to lose that functionality. Thanks.

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How to copy the value of a cell I click to the current active cell

    This version uses a double click.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-08-2014
    Location
    Orlando, Florida
    MS-Off Ver
    2010
    Posts
    10

    Re: How to copy the value of a cell I click to the current active cell

    I like it. I also added a CheckBox to allow toggling the DoubleClick functionality on and off.

    Like this:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    'Use a checkbox to toggle on/off the DoubleClick functionality
    If CheckBox1.Value = False Then Exit Sub
    'Predefined schedule times should be located within A1:J3 only
    If Target.Cells.Count > 1 Or Target.Cells.Row > 3 Or Target.Cells.Column > 10 Then GoTo 200
    Range(LastCell).Value = Target.Value
    200 Cancel = True
    End Sub

  8. #8
    Registered User
    Join Date
    08-08-2014
    Location
    Orlando, Florida
    MS-Off Ver
    2010
    Posts
    10

    Re: How to copy the value of a cell I click to the current active cell

    Last question... I think.

    How would I make the next cell selection move to the cell to the right?
    Example, If the active cell is E4, then I DoubleClick A1 to add the contents of that cell to E4, how do I automatically make the next active cell F4 (move one to the right from the original active cell)?

  9. #9
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How to copy the value of a cell I click to the current active cell

    Insert this line before line 200


    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    08-08-2014
    Location
    Orlando, Florida
    MS-Off Ver
    2010
    Posts
    10

    Re: How to copy the value of a cell I click to the current active cell

    Thanks, mehmetcik... I actually tried that already, it moves one cell over from where you DoubleClick, but not from the previously active cell. I want the user to be able to fill in the next field (to the right) without having to click on it before DoubleClicking the hours selection above. I hope that makes sense. T

  11. #11
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How to copy the value of a cell I click to the current active cell

    My apologies.

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    08-08-2014
    Location
    Orlando, Florida
    MS-Off Ver
    2010
    Posts
    10

    Re: How to copy the value of a cell I click to the current active cell

    That's beautiful!!! Can't thank you enough.

+ 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] copy and paste in current active cell, and need current date then scroll down 140 lines
    By vengatvj in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-04-2013, 03:40 AM
  2. Replies: 8
    Last Post: 05-20-2012, 06:06 PM
  3. [SOLVED] VBA - Can I select a new active cell based on the value of the current active cell?
    By GrumpyOldBastard in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-08-2012, 07:05 PM
  4. Reference to cell above the current active cell
    By nsv in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-26-2006, 06:34 AM
  5. Mouse click on cell does not make cell active
    By Jerry in forum Excel General
    Replies: 2
    Last Post: 05-01-2006, 05:40 PM

Tags for this Thread

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