View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Looping Question

Hi Ryan

I have just modified your code to group the rows with an even indent level;
but I am not sure whether this is what you are looking for..(coz I am bit
confused with your first loop). Try and feedback so as to be clear...

Sub Grp()
Dim lngRow As Long
Sheets("Sheet3").Select
For lngRow = Cells(Rows.Count, "B").End(xlUp).Row To 2 Step -1
If Range("B" & lngRow) < "" And _
Range("B" & lngRow).IndentLevel 0 And _
Range("B" & lngRow).IndentLevel Mod 2 = 0 Then
Range("B" & lngRow).Rows.Group
End If
Next lngRow
End Sub



If this post helps click Yes
---------------
Jacob Skaria


"ryguy7272" wrote:

This code will go through the used range and do the grouping for the cells
with IndentLevels that are even. However, for IndentLevels that are odd,
there is no grouping. I tried a double-loop, like For i€¦Next i and For
j€¦Next j, but that didnt work.


Sub Grp()
Dim lngRow As Long
Sheets("Sheet1").Select
For i = 12 To 0 Step -2
For lngRow = Cells(Rows.Count, "B").End(xlUp).Row To 2 Step -1
If Range("B" & lngRow) < "" And Range("B" & lngRow).IndentLevel =
(i) Then
Range("B" & lngRow).Rows.Group
End If
Next lngRow
Next i
End Sub

What do I need to do to make this group both even Indents and odd Indents?

Thanks,
Ryan---

P.S., sorry for that other post...not sure how THAT happened...
--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.