这样解决重复的问题,有重复的生成一个:
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自动填上。 附件
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 |
|
来自: 周珏 > 《EXCEL的学习》