+ Reply to Thread
Results 1 to 5 of 5

Help with onclick data select

Hybrid View

  1. #1
    Registered User
    Join Date
    11-24-2011
    Location
    FL
    MS-Off Ver
    Excel 2003
    Posts
    3

    Help with onclick data select

    Hi, I tried many times with macros but wasn't success, I don't know about VBscript on excel 2010. Anybody can help me write the macro for a button that every time I select a cell in the same sheet (B4 to L19) and hit the button, I can select value number in the cell and paste it in C22 cell so that I can do other calculation. Thank you very much.
    Hoang

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Help with onclick data select

    Hi,

    One way (which would also avoid the need for a button) would be the Sheet 'Before Double Click' event. i.e.

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
        If Not Intersect(Target, Range("B4:L19")) Is Nothing Then
            Target.Copy Destination:=Range("C22")
            Cancel = True
        End If
    
    
    End Sub
    double click any cell in the range B4:L19 and the value will be placed in C22

    Regards
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    11-24-2011
    Location
    FL
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Help with onclick data select

    Hello Richards, I really appreciate your help.
    Seems like I get closer to what I want but the copy value is changed (I just wanna to copy the value, not the equation). I attached here the spreadsheet to see if you can help.
    Thank you.
    Hoang
    Last edited by hoang; 11-25-2011 at 11:13 AM.

  4. #4
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Help with onclick data select

    hi, hoang, try to change this line in Richard's code:

    Target.Copy Destination:=Range("C22")
    to this one:

    Range("C22") = Target.Value

  5. #5
    Registered User
    Join Date
    11-24-2011
    Location
    FL
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Help with onclick data select

    Hello watersev,
    The macro runs great now. I'm happy with it.
    Thank you guys so much.
    Hoang.
    @Richard: thank you again.

+ 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