分享

源码学习

 周珏 2009-01-06
这样解决重复的问题,有重复的生成一个:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
   
    Dim sh As Worksheet
    Application.DisplayAlerts = False
    For Each sh In Worksheets
        If sh.CodeName <> "Sheet1" Then sh.Delete
    Next
    Application.DisplayAlerts = True
    With Sheet1
        For c = 1 To .Range("a65536").End(xlUp).Row
            If Application.CountIf(.Range("a1:a" & c), .Cells(c, 1)) = 1 Then
               Sheets.Add(After:=Sheets(Sheets.Count)).Name = .Cells(c, 1)
            End If
        Next
        .Select
    End With
End Sub
 

如何在工作表中自动填数

工作表中能否做成输入头尾数,中间就自动填上。
如在D12输入4,D20输入12,中间的5-11自动填上;
在I16输入8,I23输入15,中间的9-14自动填上。

附件

Book1.rar (2 KB)

2009-1-3 09:38, 下载次数: 12

 
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
Dim n&, col&, i&
n = Target.Row - 1
col = Target.Column
For i = n To 1 Step -1
    If Cells(i, col) <> "" Then
        For j = i + 1 To n
            Cells(j, col) = Cells(j - 1, col) + 1
        Next j
        Exit Sub
    End If
Next i
End Sub

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多