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

ArnMan

Board Regular
Joined
Aug 30, 2017
Messages
64
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
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
53,746
Office Version
365
Platform
Windows
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
 

ArnMan

Board Regular
Joined
Aug 30, 2017
Messages
64
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
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
53,746
Office Version
365
Platform
Windows
You are welcome.
 

Watch MrExcel Video

Forum statistics

Threads
1,102,858
Messages
5,489,306
Members
407,686
Latest member
Chuck1960

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top