Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to concatenate previously selected cells
Hello, everyone!
I'm trying to write a macro that would allow me to concatenate the contents of several already selected (but not adjacent) cells into one cell. In other words, I want to be able to go to a worksheet, select several different cells by using the Ctrl key and then run the macro to concatenate what is in those cells into one cell, preferably the upper leftmost cell of the ones selected. Any help on this would be greatly appreciate. My first post, so don't chastise me too much if what I'm asking has a simple solution. Thanks, |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to concatenate previously selected cells
How about:
Sub Macro1() Dim r As Range Dim rr As Range Dim i As Integer Dim t As String i = 0 t = "" For Each r In Selection If i = 0 Then i = 1 Set rr = r End If t = t & r.Value Next rr.Value = t End Sub I only tried it once. -- Gary's Student "Grumpy" wrote: Hello, everyone! I'm trying to write a macro that would allow me to concatenate the contents of several already selected (but not adjacent) cells into one cell. In other words, I want to be able to go to a worksheet, select several different cells by using the Ctrl key and then run the macro to concatenate what is in those cells into one cell, preferably the upper leftmost cell of the ones selected. Any help on this would be greatly appreciate. My first post, so don't chastise me too much if what I'm asking has a simple solution. Thanks, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I get macro to unmerge cells that have been previously merg | New Users to Excel | |||
Clearing what you have previously selected | Excel Programming | |||
Macro to take selected cells times a selected cell | Excel Programming | |||
referencing previously selected cells after macro execution begins | Excel Programming | |||
Selection the previously selected cell | Excel Programming |