Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Example: I have selected any row and any column, let's say D6. The data I am looking for is in column H. So, I want the macro to copy the data in row 6, and column H, i.e. H6.

If I have selected G14, the macro shall copy the data in cell H14, etc.

share|improve this question
 Range("H" & ActiveCell.Row).Copy

call it on Worksheet_SelectionChange

if you only want the value to use, just assign

Range("H" & ActiveCell.Row).Value 

to a variable and use it in your calculations and return where you will

share|improve this answer

I wrote a macro for that. It always copies the selected cell and pastes the data on column H at the same row.

Sub NewMacro()
    Cells(ActiveCell.Row, 8).Select
End Sub
share|improve this answer
Thanks! Not really what I asked for, but it still might be a part of a solution. I want to copy the value in column 8 of the row I have selected (selected a cell). Then I am to use that value in further calculations... maybe: Cells(ActiveCell.Row, 8).Select Selection.Copy etc I'll try it! – Tommy Jun 2 '10 at 21:03

You've had a few days so may have reached an answer already, but extending the answer already suggestedn, I think the below will do what you ask:

Sub CopyFromColH()
    'Save the current location
    Dim TargetCell As Range
    Set TargetCell = ActiveCell.Range("A1")

    'Copy from same row in H
    Cells(ActiveCell.Row, 8).Select

    'Paste to original location, as saved above
End Sub
share|improve this answer
datatoo's later suggestion is much cleaner (and more efficent; simply better, really) so I suggest using that! I'd vote datatoo's answer up if I could, but I lack the reputation at the moment. – DMA57361 Jun 11 '10 at 10:55
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

  If Not Intersect(Target, Range("U:U")) Is Nothing Then
    Cancel = True

    If Application.CountIf(Sheets("AA").Range("L:L"), Target.Value) = 0 Then
      Cells(Target.Row, 12).Value = Target.Value
    End If
  End If

End Sub
share|improve this answer
Hi Farrakh. Welcome to SO. Please consider adding some description to your answer to help us to understand your solution – CallumDA33 May 16 at 10:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .