Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I get macro to unmerge cells that have been previously merg HankY New Users to Excel 2 December 8th 05 05:52 AM
Clearing what you have previously selected T8RSP[_4_] Excel Programming 1 November 7th 05 10:28 AM
Macro to take selected cells times a selected cell Craig Excel Programming 4 October 24th 05 12:54 AM
referencing previously selected cells after macro execution begins Glenn Excel Programming 5 October 15th 04 12:52 AM
Selection the previously selected cell David Excel Programming 3 June 3rd 04 02:16 PM


All times are GMT +1. The time now is 08:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"