Results 1 to 4 of 4

Thread: Is there a way to copy a value in the cell next to target cell?

  1. #1
    Board Regular
    Join Date
    Aug 2017
    Posts
    63
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Is there a way to copy a value in the cell next to target cell?

    Hello, I have a small script and it works for what it is designed for

    Code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
        If Not Intersect(Target, Range("G1:G600")) Is Nothing Then
            Target.Copy
        End If
    End Sub
    Basically it does is monitor G column and when I click anywhere in the G column it will take that cells value and copy it into the clipboard. Then I can paste into Putty. Keeps from having to continually type commands over and over.
    Some commands require a number of some sorts to go along with it.
    Example G10 Value is Gain_adj and I type in H10 25
    I would like to click in G10 and get the value of G10 and H10

    Gain_adj 25
    Not every cell in H column will have a value that I type in.

    Is there something I can change to accomplish this?

    Thank you very much

  2. #2
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    50,813
    Post Thanks / Like
    Mentioned
    57 Post(s)
    Tagged
    11 Thread(s)

    Default Re: Is there a way to copy a value in the cell next to target cell?

    So if you want to copy columns G and H in that row when you select a cell in column G, try:
    Code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If Not Intersect(Target, Range("G1:G600")) Is Nothing Then
            Target.Resize(1, 2).Copy
        End If
    End Sub
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

  3. #3
    Board Regular
    Join Date
    Aug 2017
    Posts
    63
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Is there a way to copy a value in the cell next to target cell?

    Quote Originally Posted by Joe4 View Post
    So if you want to copy columns G and H in that row when you select a cell in column G, try:
    Code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If Not Intersect(Target, Range("G1:G600")) Is Nothing Then
            Target.Resize(1, 2).Copy
        End If
    End Sub
    Thank you very much, I think it will work for what I am looking for.

    Thank you very much for all your help

  4. #4
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    50,813
    Post Thanks / Like
    Mentioned
    57 Post(s)
    Tagged
    11 Thread(s)

    Default Re: Is there a way to copy a value in the cell next to target cell?

    You are welcome.
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •