PC Review


Reply
Thread Tools Rate Thread

How do I set a range to the currently selected cells?

 
 
vcgreen@gmail.com
Guest
Posts: n/a
 
      4th Jan 2008
Hi

Would be very grateful for a solution to this... I need to run a macro
against a currently selected range of cells. The macro creates a new
cell based on the concatenated contents of the selected cells (which
will always be just a single set in a column) like so:

Selected cells: New cell:

.. ABC ABCDEFGHI
.. DEF
.. GHI

However I can't find a way to do this as there is no 'SelectedCells'
or 'SelectedRange' property for Worksheet object.

Thanks in anticipation

Vaughan

 
Reply With Quote
 
 
 
 
Wigi
Guest
Posts: n/a
 
      4th Jan 2008
Set rCells = Selection

Here I used rCells as the range variable holding the cells in the selection.

--
Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music


"(E-Mail Removed)" wrote:

> Hi
>
> Would be very grateful for a solution to this... I need to run a macro
> against a currently selected range of cells. The macro creates a new
> cell based on the concatenated contents of the selected cells (which
> will always be just a single set in a column) like so:
>
> Selected cells: New cell:
>
> .. ABC ABCDEFGHI
> .. DEF
> .. GHI
>
> However I can't find a way to do this as there is no 'SelectedCells'
> or 'SelectedRange' property for Worksheet object.
>
> Thanks in anticipation
>
> Vaughan
>
>

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      4th Jan 2008
I would create a UDF like so

Function Conc(rng As Range)
Dim cell As Range
For Each cell In rng
Conc = Conc & cell.Value
Next cell
End Function


and use it in a worksheet like so

=CONC(A1:A3)

or even

=CONC((A1,B9,M7))

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

<(E-Mail Removed)> wrote in message
news:6334143c-3bf0-40d8-a853-(E-Mail Removed)...
> Hi
>
> Would be very grateful for a solution to this... I need to run a macro
> against a currently selected range of cells. The macro creates a new
> cell based on the concatenated contents of the selected cells (which
> will always be just a single set in a column) like so:
>
> Selected cells: New cell:
>
> . ABC ABCDEFGHI
> . DEF
> . GHI
>
> However I can't find a way to do this as there is no 'SelectedCells'
> or 'SelectedRange' property for Worksheet object.
>
> Thanks in anticipation
>
> Vaughan
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set Range Using Selected Cells =?Utf-8?B?UGFwdXR4aQ==?= Microsoft Excel Programming 3 2nd May 2006 06:32 PM
Compare a selected Range with a Named range and select cells that do not exist PCLIVE Microsoft Excel Programming 1 18th Oct 2005 07:09 PM
max/min of a selected range of cells Srikanth Ganesan Microsoft Excel Programming 1 1st Sep 2004 10:31 PM
Re: sum of selected cells in a range Don Guillett Microsoft Excel Worksheet Functions 2 19th Mar 2004 08:53 PM
Re: sum of selected cells in a range Andy B Microsoft Excel Worksheet Functions 0 19th Mar 2004 05:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:43 PM.