Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
'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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you Tom
The answer is very usefuf and pertinent. |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi chris
Thank you for this precious help. That is all I needed Jac |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Limiting selection in a cell AND linking that selection to a list | Excel Discussion (Misc queries) | |||
SUM of areas | Excel Worksheet Functions | |||
Copy Selection - Transpose Selection - Delete Selection | Excel Discussion (Misc queries) | |||
Print Areas | Excel Discussion (Misc queries) | |||
Identifying a selection of a selection of a range | Excel Worksheet Functions |