Concatonate

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like very much to be able to place the cursor immediately below a
line that contains data in cols a,b,c,d,e,
Then click on a macro and that macro would concatonate all the data in the
line above into the selected cell.
Can this be done
Thanks
 
This does it by selecting a cell

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

On Error GoTo EndMacro
Application.EnableEvents = False
With Target
If .Row > 1 Then
.Value = Cells(.Row - 1, "A").Value & Cells(.Row - 1, "B").Value
& _
Cells(.Row - 1, "C").Value & Cells(.Row - 1, "D").Value
& _
Cells(.Row - 1, "E").Value
End If
End With
EndMacro:
Application.EnableEvents = True
End Sub


'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.





--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top