Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I set a range to the currently selected cells?

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default How do I set a range to the currently selected cells?

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


" 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default How do I set a range to the currently selected cells?

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)

wrote in message
...
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
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 to recycle through cells in a selected range stub Excel Programming 2 December 6th 07 09:00 PM
Put data in range of selected cells MusicMaker Excel Discussion (Misc queries) 3 September 6th 07 11:55 AM
Set Range Using Selected Cells Paputxi Excel Programming 3 May 2nd 06 06:32 PM
Compare a selected Range with a Named range and select cells that do not exist PCLIVE Excel Programming 1 October 18th 05 07:09 PM
max/min of a selected range of cells Srikanth Ganesan[_2_] Excel Programming 1 September 1st 04 10:31 PM


All times are GMT +1. The time now is 01:20 AM.

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

About Us

"It's about Microsoft Excel"