Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Selection and Areas

Hi everyone
I'm trying to find a way to loop on every area in a multiple selection and the help provided is rather concise
' ****
Sub NoMultiAreaSelection(
NumberOfSelectedAreas = Selection.Areas.Coun
If NumberOfSelectedAreas 1 The
MsgBox "You cannot carry out this command on multi-area selections
End I
End Su
' ****
I would like to get some information like the area's address for each area in the current selection. Something like this
****
Sub MultiAreaSelection(
Dim NumberOfSelectedAreas As Integer, intI As Intege
NumberOfSelectedAreas = Selection.Areas.Coun
For intI = 1 To NumberOfSelectedArea
'How can I get each area's address, for example
Next int
End Su
' ****
Another question about Selection
Why, in VBA, when I type "Selection" followed by a dot, I do not get any option suggested. The same as when an object is declared as Object, a too general object

Thanks to anyone who can help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Selection and Areas

Jac,

Try something like

Dim Ar As Range
For Each Ar In Selection.Areas
Debug.Print Ar.Address
Next Ar


Why, in VBA, when I type "Selection" followed by a dot, I do

not get any option suggested.

The reason is that Selection is a generic Object, not a specific
type of object. It usually refers to a range of cells, but may
refer to a ChartObject, a Shape, or whatever happens to be
selected at run time. When you are writing code, the editor has
no idea what type of object might be selected, so no Intellisense
is provided.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Jac Tremblay" wrote in
message
...
Hi everyone,
I'm trying to find a way to loop on every area in a multiple

selection and the help provided is rather concise:
' *****
Sub NoMultiAreaSelection()
NumberOfSelectedAreas = Selection.Areas.Count
If NumberOfSelectedAreas 1 Then
MsgBox "You cannot carry out this command on multi-area

selections"
End If
End Sub
' *****
I would like to get some information like the area's address

for each area in the current selection. Something like this:
*****
Sub MultiAreaSelection()
Dim NumberOfSelectedAreas As Integer, intI As Integer
NumberOfSelectedAreas = Selection.Areas.Count
For intI = 1 To NumberOfSelectedAreas
'How can I get each area's address, for example?
Next intI
End Sub
' *****
Another question about Selection:
Why, in VBA, when I type "Selection" followed by a dot, I do

not get any option suggested. The same as when an object is
declared as Object, a too general object?

Thanks to anyone who can help.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Selection and Areas

Hi Chip
Thank you very much for this precious help. It works fine for me
For the Selection object, is there a way to restrict the range of objects so that Intellisense is provided? And also, is there a way to check the properties or methods availaible for a specific case of the Selection object, like the selection of worksheet cells
Thanks again for your help.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Selection and Areas

No Jac. Intellisense will not be provided for selection.

You can substitute a specific object and build your code, then go back and
replace it with selection.

or if you know what the selection will be (and you more than likely will),
define a variable to that type

Dim rng as Range


set rng = Selection

' now use rng and you will get the intellisense.

If you are recording your code, then you need to clean it up anyway.

--
Regards,
Tom Ogilvy


"Jac Tremblay" wrote in message
...
Hi Chip,
Thank you very much for this precious help. It works fine for me.
For the Selection object, is there a way to restrict the range of objects

so that Intellisense is provided? And also, is there a way to check the
properties or methods availaible for a specific case of the Selection
object, like the selection of worksheet cells?
Thanks again for your help.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Selection and Areas

You can do something like this..
Dim MyRange as Range 'Do a complie after you type the Dim statemen
Set MyRange = Selection
MyRange.?
Now you can see all the members of a range objec


----- Jac Tremblay wrote: ----

Hi Chip
Thank you very much for this precious help. It works fine for me
For the Selection object, is there a way to restrict the range of objects so that Intellisense is provided? And also, is there a way to check the properties or methods availaible for a specific case of the Selection object, like the selection of worksheet cells
Thanks again for your help.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Selection and Areas

'Do a complie after you type the Dim statement

?? why do a compile ?? That wouldn't be required to the best of my
knowledge.

--
Regards,
Tom Ogilvy

"chris" wrote in message
...
You can do something like this...

Dim MyRange as Range 'Do a complie after you type the Dim statement
Set MyRange = Selection
MyRange.??
Now you can see all the members of a range object


----- Jac Tremblay wrote: -----

Hi Chip,
Thank you very much for this precious help. It works fine for me.
For the Selection object, is there a way to restrict the range of

objects so that Intellisense is provided? And also, is there a way to check
the properties or methods availaible for a specific case of the Selection
object, like the selection of worksheet cells?
Thanks again for your help.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Selection and Areas

Thank you Tom
The answer is very usefuf and pertinent.
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Selection and Areas

Hi chris
Thank you for this precious help. That is all I needed
Jac
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
Limiting selection in a cell AND linking that selection to a list Lisa Excel Discussion (Misc queries) 1 July 28th 09 05:00 PM
SUM of areas Natalie Excel Worksheet Functions 7 July 4th 09 01:08 PM
Copy Selection - Transpose Selection - Delete Selection Uninvisible Excel Discussion (Misc queries) 2 October 23rd 07 04:18 PM
Print Areas Steve COR Excel Discussion (Misc queries) 3 August 31st 07 05:48 PM
Identifying a selection of a selection of a range swimfast Excel Worksheet Functions 1 March 1st 07 02:51 AM


All times are GMT +1. The time now is 11:51 PM.

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"