Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Excel 2007 ang "Group row" option

hi all,

I'm working on excel 2007 and using the "group row option"....

I have organised the data and use the feature to group some rows...

how can I understand, from vba, if I have select the first or the last
collo of the group????

thanks

cheers

Vit
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Excel 2007 ang "Group row" option

Hi Vit,

Someone may have a better way of doing this and I will be interested if they
do. However, this is how I would do it.

Firstly on the worksheet when you select the range to group then go into
named ranges and name the range eg. Group1, Group2 etc.

Then in VBA you can identify those named ranges and assign them to range
variables.

From there you can calculate the column number within the range. (I have
never been able to directly return the relative column number withing a range
assigned to a variable).

You may wish to use intersect in a case statement to first establish what
range the selection is in. My example only uses one group.


Dim rngMyRng As Range
Dim firstColMyRng As Long
Dim selectionCol As Long
Dim selectColMyRng As Long
Dim isect As Object

Set rngMyRng = Range("Group1")

'following needs to be within case to establish which
'range the selection is in
Set isect = Application.Intersect(Selection, rngMyRng)

If isect Is Nothing Then
MsgBox "No ranges intersect with selection"
Exit Sub
End If

'Identify the first column number of the assigned range
firstColMyRng = rngMyRng.Cells(1, 1).Column

'Identify the column number of the selected cell/range
selectionCol = Selection.Column

'Therefore relative column number in named range is:
selectColMyRng = selectionCol - firstColMyRng + 1

Feel free to get back to me if you need more info or clarification.

--
Regards,

OssieMac


"Vit" wrote:

hi all,

I'm working on excel 2007 and using the "group row option"....

I have organised the data and use the feature to group some rows...

how can I understand, from vba, if I have select the first or the last
collo of the group????

thanks

cheers

Vit

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
Excel 2007: top of screen "File Name [Group]", how to remove [Grou Lightjag Excel Discussion (Misc queries) 3 April 2nd 23 07:08 PM
2007 Need macro to auto set option buttons all to "Yes" or "No" Paula Excel Worksheet Functions 1 October 20th 09 08:07 PM
Restoring "Sized with Window" option in Excel 2007? Pim den Hartog Charts and Charting in Excel 1 January 8th 09 02:34 PM
Excel 2007 "Find" option won't work. Nerdophile Excel Worksheet Functions 2 September 19th 07 06:36 PM
Custom Menus & "Begin a Group" option JMMach[_2_] Excel Programming 5 June 12th 05 01:08 PM


All times are GMT +1. The time now is 09: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"