Auto Group the config file

Source: Internet
Author: User

Dim levalmax as integer

Sub auto_level_exit ()



Oldrow = 0

Linmax = sheet1.usedrange. Rows. Count

Colonmax = sheet1.usedrange. Columns. Count

'Msgbox "auto_level_exit oldrow is:" & oldrow

I = 100.

Levalmax = 1


For I = linmax to 1 step-1

Str1 = sheet1.cells (I, 1)

Str2 = right (str1, 5)

If str2 = "exit" or str2 = "exit" then

Oldrow = newrow

Newrow = I

For J = I-1 to 1 step-1

Str3 = sheet1.cells (J, 1)

Str4 = left (str3, Len (str1)-1)

Str5 = right (str4, 4)

If str5 <> "" then

Oldrow = J + 1

J = 0

If oldrow <> newrow then

Rows (oldrow & ":" & newrow). Select

Selection. Rows. Group

Exit

End if

End if

Next

'Get number of space to calculate the level

Spacelen = Len (str1)

Levelnum = spacelen/4

If levalmax <levelnum then

Levalmax = levelnum

End if

End if

Next


End sub

Sub auto_level_echo ()



Oldrow = 0

Linmax = sheet1.usedrange. Rows. Count

Colonmax = sheet1.usedrange. Columns. Count

'Msgbox "oldrow is:" & oldrow


For I = 1 to linmax

Str1 = sheet1.cells (I, 1)

Str2 = left (str1, 6)

If str2 = "Echo" then

Oldrow = newrow

Newrow = I

If oldrow <> 0 then

Rows (oldrow + 1 & ":" & newrow-2). Select

Selection. Rows. Group

End if

End if

If I = linmax-7 then

Rows (newrow + 1 & ":" & I). Select

Selection. Rows. Group

End if


Next



End sub

Sub auto_nolevel_echo ()



Oldrow = 0

Linmax = sheet1.usedrange. Rows. Count

Colonmax = sheet1.usedrange. Columns. Count

'Msgbox "oldrow is:" & oldrow



'Rowlevel = sheet1.outline. summaryrow

'Colormnlevel = sheet1.outline. summarycolumn



For I = 1 to levalmax-1 'linmax

Rows (1 & ":" & linmax). Select

Selection. Rows. ungroup

Next





Levalmax = 0


End sub

Sub auto_level_config ()

Dim I, j as integer

Dim str1, str2, str3 as string

Dim linemax, colonmax as integer


Linmax = sheet1.usedrange. Rows. Count


Colonmax = sheet1.usedrange. Columns. Count


'Msgbox "line is:" & linmax & "column is" & colonmax

Oldrow = 1

Newrow = 5


Auto_level_echo

Auto_level_exit


End sub

Sub nogroup ()

'

'Nogroup macro

'


Rows ("1742: 1747"). Select

Selection. Copy

Application. cutcopymode = false

Selection. Rows. ungroup

End sub


Auto Group the config file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.