ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Concatonate (https://www.excelbanter.com/excel-discussion-misc-queries/74707-concatonate.html)

pcor

Concatonate
 
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


Bob Phillips

Concatonate
 
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)

"pcor" wrote in message
...
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





All times are GMT +1. The time now is 11:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com