Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Collapse away VBA lines with deep indentation

In vi/vim, one can collapse away code of a certain level of
indentation (and all subordinate levels). Is there a way to do this
in the VB editor? Without such a feature, it's rather hard to see
which code belongs within which flow control structures when the code
runs over a page long.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Collapse away VBA lines with deep indentation

Jacob Skaria helped me with this a few months back:

Dim arrINT(10) As Long
Sub GroupbyIndexLevels2()
Dim lngRow As Long
Dim intCIL As Integer
Dim intPIL As Integer
For lngRow = 1 To Cells(Rows.Count, "B").End(xlUp).Row
intCIL = Range("B" & lngRow).IndentLevel
If intCIL 0 Then
If intCIL intPIL Then
arrINT(intCIL) = lngRow
ElseIf intCIL < intPIL Then
GroupRows2 intCIL, lngRow
End If
intPIL = intCIL
End If
Next lngRow
GroupRows2 1, lngRow
ActiveSheet.Outline.ShowLevels RowLevels:=1
End Sub

Sub GroupRows2(intIND As Integer, lngRow As Long)
Dim intTemp As Integer
For intTemp = intIND + 1 To UBound(arrINT)
If arrINT(intTemp) < 0 Then
Rows(arrINT(intTemp) & ":" & lngRow - 1).Group
arrINT(intTemp) = 0
End If
Next
End Sub


Sub UnGrp()
Range("A1").Select
Selection.ClearOutline
End Sub

HTH,
Ryan---

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


"Paul" wrote:

In vi/vim, one can collapse away code of a certain level of
indentation (and all subordinate levels). Is there a way to do this
in the VB editor? Without such a feature, it's rather hard to see
which code belongs within which flow control structures when the code
runs over a page long.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default Collapse away VBA lines with deep indentation

You could just select all the code and use SHIFT+TAB or EditOutdent.

Mind you isn't it easier to follow code that is well indented?

If the problem is that it's badly indented then there are add-ins that
can help.

Personally if I have to deal with badly indented code I just remove
all the indentation and then redo it.

Sometimes that actually helps, for me anyway, in understanding the
flow/structure.

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
Level of Indentation of a cell Muk Excel Programming 4 August 31st 11 01:29 AM
Indentation CB Excel Discussion (Misc queries) 3 March 11th 09 05:17 PM
Indentation AndrewEdmunds Excel Discussion (Misc queries) 0 October 7th 08 10:20 PM
Conditional formatting - based on indentation [email protected] Excel Programming 6 March 10th 08 02:24 PM
using vlookup for words w/different indentation HK Excel Worksheet Functions 3 September 15th 06 08:39 PM


All times are GMT +1. The time now is 02:45 AM.

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"