Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Grouping According to IndentLevel

I am trying to arrange elements into groups. My code is below:
Sub Grp()
Dim lngRow As Long

Sheets("Sheet1").Select

For i = 6 To 0 Step -1
For lngRow = Cells(Rows.Count, "B").End(xlUp).Row To 4 Step -1
If Range("B" & lngRow) < "" And .IndentLevel = (i) Then
Range("B" & lngRow & ":B" & lngRow).Rows.Group
End If
Next lngRow
Next i

End Sub

Basically, I want to start on Row 4, go to the end of the used range, and
group all data according to the €˜Indent of each Row. There can be 0 to 6
IndentLevels.
The code fails on this line:
If Range("B" & lngRow) < "" And .IndentLevel = (i) Then

The message I get says €˜Compile Error: Invalid or unqualified refernce.
What am I doing wrong?

Thanks,
Ryan---


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Grouping According to IndentLevel

What object is ".IndentLevel" referring to? Usually, you would have
something like

With ActiveCell
ID = .IndentLevel
End With

or something like that.

HTH,

Eric

"ryguy7272" wrote:

I am trying to arrange elements into groups. My code is below:
Sub Grp()
Dim lngRow As Long

Sheets("Sheet1").Select

For i = 6 To 0 Step -1
For lngRow = Cells(Rows.Count, "B").End(xlUp).Row To 4 Step -1
If Range("B" & lngRow) < "" And .IndentLevel = (i) Then
Range("B" & lngRow & ":B" & lngRow).Rows.Group
End If
Next lngRow
Next i

End Sub

Basically, I want to start on Row 4, go to the end of the used range, and
group all data according to the €˜Indent of each Row. There can be 0 to 6
IndentLevels.
The code fails on this line:
If Range("B" & lngRow) < "" And .IndentLevel = (i) Then

The message I get says €˜Compile Error: Invalid or unqualified refernce.
What am I doing wrong?

Thanks,
Ryan---


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Grouping According to IndentLevel

Yep, I thought of that too. I tried it before I posted the question; didn't
work. Other ideas?

Thanks,
Ryan---


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Eric G" wrote:

What object is ".IndentLevel" referring to? Usually, you would have
something like

With ActiveCell
ID = .IndentLevel
End With

or something like that.

HTH,

Eric

"ryguy7272" wrote:

I am trying to arrange elements into groups. My code is below:
Sub Grp()
Dim lngRow As Long

Sheets("Sheet1").Select

For i = 6 To 0 Step -1
For lngRow = Cells(Rows.Count, "B").End(xlUp).Row To 4 Step -1
If Range("B" & lngRow) < "" And .IndentLevel = (i) Then
Range("B" & lngRow & ":B" & lngRow).Rows.Group
End If
Next lngRow
Next i

End Sub

Basically, I want to start on Row 4, go to the end of the used range, and
group all data according to the €˜Indent of each Row. There can be 0 to 6
IndentLevels.
The code fails on this line:
If Range("B" & lngRow) < "" And .IndentLevel = (i) Then

The message I get says €˜Compile Error: Invalid or unqualified refernce.
What am I doing wrong?

Thanks,
Ryan---


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Grouping According to IndentLevel

Try tacking "Activesheet." in front of all the Ranges, and you'll still need
to qualify the .IndentLevel with Activecell.IndentLevel or
Cells(1,1).IndentLevel, etc.

Eric

"ryguy7272" wrote:

Yep, I thought of that too. I tried it before I posted the question; didn't
work. Other ideas?

Thanks,
Ryan---


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Eric G" wrote:

What object is ".IndentLevel" referring to? Usually, you would have
something like

With ActiveCell
ID = .IndentLevel
End With

or something like that.

HTH,

Eric

"ryguy7272" wrote:

I am trying to arrange elements into groups. My code is below:
Sub Grp()
Dim lngRow As Long

Sheets("Sheet1").Select

For i = 6 To 0 Step -1
For lngRow = Cells(Rows.Count, "B").End(xlUp).Row To 4 Step -1
If Range("B" & lngRow) < "" And .IndentLevel = (i) Then
Range("B" & lngRow & ":B" & lngRow).Rows.Group
End If
Next lngRow
Next i

End Sub

Basically, I want to start on Row 4, go to the end of the used range, and
group all data according to the €˜Indent of each Row. There can be 0 to 6
IndentLevels.
The code fails on this line:
If Range("B" & lngRow) < "" And .IndentLevel = (i) Then

The message I get says €˜Compile Error: Invalid or unqualified refernce.
What am I doing wrong?

Thanks,
Ryan---


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Grouping According to IndentLevel

Thanks again Eric. Did that work for you? Still can't get this working.
This is what I have now:

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

Maybe the Cells are not being properly selected...
Any more ideas?




--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Eric G" wrote:

Try tacking "Activesheet." in front of all the Ranges, and you'll still need
to qualify the .IndentLevel with Activecell.IndentLevel or
Cells(1,1).IndentLevel, etc.

Eric

"ryguy7272" wrote:

Yep, I thought of that too. I tried it before I posted the question; didn't
work. Other ideas?

Thanks,
Ryan---


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Eric G" wrote:

What object is ".IndentLevel" referring to? Usually, you would have
something like

With ActiveCell
ID = .IndentLevel
End With

or something like that.

HTH,

Eric

"ryguy7272" wrote:

I am trying to arrange elements into groups. My code is below:
Sub Grp()
Dim lngRow As Long

Sheets("Sheet1").Select

For i = 6 To 0 Step -1
For lngRow = Cells(Rows.Count, "B").End(xlUp).Row To 4 Step -1
If Range("B" & lngRow) < "" And .IndentLevel = (i) Then
Range("B" & lngRow & ":B" & lngRow).Rows.Group
End If
Next lngRow
Next i

End Sub

Basically, I want to start on Row 4, go to the end of the used range, and
group all data according to the €˜Indent of each Row. There can be 0 to 6
IndentLevels.
The code fails on this line:
If Range("B" & lngRow) < "" And .IndentLevel = (i) Then

The message I get says €˜Compile Error: Invalid or unqualified refernce.
What am I doing wrong?

Thanks,
Ryan---


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 199
Default Grouping According to IndentLevel

I don't understand what you are doing, but this code works without error
in my side. if rows are arranged to IndentLevel, the result would be messed.

Sub Grp()
Dim lngRow As Long
Sheets("Sheet1").Select
For i = 6 To 0 Step -1
For lngRow = Cells(Rows.Count, "B").End(xlUp).Row To 4 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

Keiji

ryguy7272 wrote:
Thanks again Eric. Did that work for you? Still can't get this working.
This is what I have now:

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

Maybe the Cells are not being properly selected...
Any more ideas?




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Grouping According to IndentLevel

I should have seen that! Thanks so much!!!
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"keiji kounoike" <"kounoike AT mbh.nifty." wrote:

I don't understand what you are doing, but this code works without error
in my side. if rows are arranged to IndentLevel, the result would be messed.

Sub Grp()
Dim lngRow As Long
Sheets("Sheet1").Select
For i = 6 To 0 Step -1
For lngRow = Cells(Rows.Count, "B").End(xlUp).Row To 4 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

Keiji

ryguy7272 wrote:
Thanks again Eric. Did that work for you? Still can't get this working.
This is what I have now:

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

Maybe the Cells are not being properly selected...
Any more ideas?





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
To sum by grouping Dan Excel Discussion (Misc queries) 1 January 15th 09 01:51 AM
Grouping [email protected] Excel Programming 0 April 30th 07 08:12 PM
Grouping Geoffrey Allen Excel Worksheet Functions 1 January 16th 07 12:47 AM
grouping steve Excel Programming 2 July 11th 05 04:34 PM
IndentLevel PeterW[_2_] Excel Programming 3 February 25th 04 08:32 AM


All times are GMT +1. The time now is 08:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"