ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   selection.copy - how to emulate Paste command? (https://www.excelbanter.com/excel-programming/349775-selection-copy-how-emulate-paste-command.html)

[email protected]

selection.copy - how to emulate Paste command?
 
Hi, this macro concatenates cell contents and displays them in Msgbox
and Debug window.
Now I would like to simply use the result string as a PASTE command.

Do you have any ideas?

Sub Concaten_Cells()
Text = ""
i = 0
ile = Selection.Cells.Count
For Each cell In Selection
i = i + 1
If Text < "" Then
Text = Text & ", " & cell.Text
Else
Text = cell.Text
End If
If i = ile Then
Text = Text & "."
End If
Next
MsgBox Text
Debug.Print Text
End Sub

Thanks, Tomek


N10

selection.copy - how to emulate Paste command?
 
I think you will have to write the variable "TEXT" to a cell first.

After that you can copy and paste the cell value value or simply continue to
write "TEXT" to where it is required.

N10

wrote in message
oups.com...
Hi, this macro concatenates cell contents and displays them in Msgbox
and Debug window.
Now I would like to simply use the result string as a PASTE command.

Do you have any ideas?

Sub Concaten_Cells()
Text = ""
i = 0
ile = Selection.Cells.Count
For Each cell In Selection
i = i + 1
If Text < "" Then
Text = Text & ", " & cell.Text
Else
Text = cell.Text
End If
If i = ile Then
Text = Text & "."
End If
Next
MsgBox Text
Debug.Print Text
End Sub

Thanks, Tomek




evgny[_2_]

selection.copy - how to emulate Paste command?
 
Hi tpo

What do you meen with PASTE COMAND??

Regards
yngve



All times are GMT +1. The time now is 05:37 PM.

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