发布新日志

  • excel总的下拉列表2

    2009-08-07 09:53:42

      'This should only be called at the end of list
        indent_testcases = 0
    End Function
    Private Sub 分级_Click()
        ActiveSheet.UsedRange.ClearOutline
       
        With ActiveSheet.Outline
            .AutomaticStyles = False
            .SummaryRow = xlAbove
            .SummaryColumn = xlRight
        End With
       
        Dim r As Object
        Set r = ActiveSheet.UsedRange

        Call indent_testcases(r, r.Rows.Row + 1)

      
    '    ActiveSheet.Outline.ShowLevels RowLevels:=2
    End Sub

    Private Sub 取消分级_Click()
        ActiveSheet.UsedRange.ClearOutline
    End Sub

  • excel总的下拉列表

    2009-08-07 09:50:17

    创建"下拉列表"
      选择数据区域-->执行"数据/有效性"命令->打开"数据有效性"对话框->单击"设置"选项卡->在"允许"栏选择"序列","来源"中输入数据(不含引号,用英文单引号分隔)->单击"确认"

    修改"下拉列表"
      前提条件是确保"工具->保护"没有对表单保护,然后选择"有效性",查看"来源"框里序列的引用.在"工具->宏->VB编辑器"查找相应的变量,然后再找到下拉框内容对应的表单名,最后在“格式->工作表->取消隐藏”中选择对应的表单名,然后就可以直接修改了!
    Option Explicit

    Function indent_testcases(ByRef r As Range, ByVal startrow As Integer) As Integer
        Dim level, grouplevel, i
       
        grouplevel = Len(r.Cells(startrow, 1))
          
        i = startrow
        'Count = 0
        While i <= r.Count
        'While i <= 100
            level = Len(r.Cells(i, 1))
           
            If level = grouplevel Then
                i = i + 1
            ElseIf level > grouplevel Then
                'recursively call
                i = indent_testcases(r, i)
                If i <= 0 Then Exit Function
            Else
                Debug.Print "Group: " & CStr(startrow) & " - " & CStr(i - 1)
                If Not (level = 0 And startrow = 2) Then
                Rows(CStr(startrow) & ":" & CStr(i - 1)).Group
                End If


                indent_testcases = i
                Exit Function
            End If
        Wend

Open Toolbar