Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / March 2008

Tip: Looking for answers? Try searching our database.

Need help with an excel macro to group values

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
aman - 21 Mar 2008 20:27 GMT
I am looking to group cells in excel.  I have a column called level
and the levels range from 4-6.

4
5
5
5
6
6
5
6
6
4
5
5
5
6
6
5

Group at level 4 (so select all rows with a 5 or 6 until you reach the
next level 4)
Then group at level 5 (so select all rows with a 6 and group them with
the 5 above them)

I don't know any coding so if you could please assist me with this.

Thanks
Héctor Miguel - 24 Mar 2008 00:27 GMT
hi, !

assuming your column(range) is A2:A17 and you wan to group-outline    -?-
try with a macro like this one:

Sub OutLineRows_Base_4To6()
 Dim eCell As Range
 Application.ScreenUpdating = False
 For Each eCell In Range("a2:a17")
   If eCell > 3 And eCell < 7 Then _
     eCell.EntireRow.OutlineLevel = eCell - 3
 Next
End Sub

hth,
hector.

__ original post __
>I am looking to group cells in excel.
> I have a column called level and the levels range from 4-6.
[quoted text clipped - 20 lines]
>
> I don't know any coding so if you could please assist me with this.
aman - 24 Mar 2008 19:59 GMT
On Mar 23, 7:27 pm, "Héctor Miguel" <NOhemiordiS...@PLShotmail.com>
wrote:
> hi, !
>
[quoted text clipped - 39 lines]
>
> > I don't know any coding so if you could please assist me with this.

Hector, the macro works great.  You have been great help.  Is it
possible to run the macro for all the worksheets?  I have about 10
sheets in the excel workbook.  If I could run it for all the sheet
instead of just running the macro for each sheet, it would save a lot
of time.

Thanks,
Aman
Héctor Miguel - 24 Mar 2008 20:59 GMT
hi, aman !

> ... Is it possible to run the macro for all the worksheets?
> I have about 10 sheets in the excel workbook.
> If I could run it for all the sheet instead of just running the macro for each sheet, it would save a lot of time.

could it be someting like:

Sub OutLineRows_Base_4To6()
 Dim nSheet As Worksheet, eCell As Range
 Application.ScreenUpdating = False
 For Each nSheet In Worksheets
   With nSheet
     For Each eCell In .Range( _
       .Range("a2"), .Range("a65536").End(xlUp))
       If eCell > 3 And eCell < 7 Then _
         eCell.EntireRow.OutlineLevel = eCell - 3
     Next
   End With
 Next
End Sub

hth,
hector.

> assuming your column(range) is A2:A17 and you want to group-outline    -?-
> try with a macro like this one:
[quoted text clipped - 34 lines]
>
>> I don't know any coding so if you could please assist me with this.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.