VBA练习——合并单元格 ━━━━━━━━━━━━━━━━━━━━━━━━━ Sub test() Dim sht As Worksheet Dim optype As String Dim rng As Range Dim rownum As Long optype = "clearData" 'fillData,clearData Application.ScreenUpdating = False If optype = "fillData" Then For Each sht In Worksheets If sht.Name <> "成绩表" And sht.Name <> "版权声明" Then Set rng = Worksheets("成绩表").Range("A65536").End(xlUp).Offset(1, 0) rownum = sht.Range("A1").CurrentRegion.Rows.Count - 1 sht.Range("A2").Resize(rownum, 7).Copy rng End If Next ElseIf optype = "clearData" Then Worksheets("成绩表").Range("A2:G65536").Clear End If Application.ScreenUpdating = True End Sub ━━━━━━━━━━━━━━━━━━━━━━━━━ |
|