|
Private Sub CommandButton1_Click()
Dim i As Integer
Dim flh As Long
Worksheets("TTC036G2-V").Select
'
'选中主表,请问可否根据主表名称"TTC036G2-V"自动输入:Worksheets("主表名称")?
'
flh = WorksheetFunction.CountA(Range("A:A")) '统计主表A列非零行数:flh=1779
Worksheets.Add After:=Worksheets(Worksheets.Count) '创建副表
ActiveSheet.Name = "王一" '副表名:王一(登录者姓名)
Worksheets("TTC036G2-V").Range(Cells(1, "A"), Cells(flh, "G")).Select '选中主表中A1-G1779,好像出错了,找不到原因?
Selection.Copy '复制选中表格
Worksheets("王一").Paste '副表中粘贴
'
'以下语句可否合并在上方语句中?
'
Worksheets("TTC036G2-V").Range(Cells(1, "K"), Cells(flh, "K")).Select '选中主表中K1-K1779
Selection.Copy '复制选中表格
Worksheets("王一").Range("H1").Select '选中副表中单元格“H1”,让附表中H列之前无空列
Worksheets("王一").Paste '副表中粘贴
Worksheets("TTC036G2-V").Range(Cells(1, "N"), Cells(flh, "N")).Select '选中主表中N1-N1779
Selection.Copy '复制选中表格
Worksheets("王一").Range("I1").Select '选中副表中单元格“I1”,让附表中I列之前无空列
Worksheets("王一").Paste '副表中粘贴
'
'下方两行语句可否合并为:ActiveSheet.Range(Cells(1, "A"), Cells(flh, "I")).AutoFilter field = 7, criterial:="" ,field = 8, criterial:="王一"
'
ActiveSheet.Range(Cells(1, "A"), Cells(flh, "I")).AutoFilter field = 7, criterial:="" ' 筛选I列为空的行
ActiveSheet.Range(Cells(1, "A"), Cells(flh, "I")).AutoFilter field = 8, criterial:="王一" ' 筛选H列为"王一"的行
With Worksheets("王一") '在数据行增加复选框,感谢EXCELHome大神: chxm68
For Each aa In .CheckBoxes '?
aa.Delete
With .CheckBoxes.Add(.Cells(2, 9).Left, .Cells(2, 9).Top - 2, 46.5, 19.5) '在G2增加全选的复选框
.Name = "全选" & i
.Caption = "复选框" & i
End With
Next
For i = 3 To ActiveSheet.Rows.Count
With .CheckBoxes.Add(.Cells(i, 9).Left, .Cells(i, 9).Top - 2, 46.5, 19.5) '在其它行增加复选框
.Name = "已到货" & i
.Caption = "复选框" & i
End With
Next
End With
End Sub
|
|