幼鸽开家可以一对开吗:源码学习
来源:百度文库 编辑:偶看新闻 时间:2024/05/09 09:09:05
这样解决重复的问题,有重复的生成一个:
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自动填上。
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
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
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