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

ArnMan

Board Regular
Joined
Aug 30, 2017
Messages
69
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
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
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,949
Members
448,534
Latest member
benefuexx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top