Excel VBA单元格选择复制

Sub prt()
    Debug.Print Workbooks("工作簿1.xlsx").Name
    Debug.Print Worksheets.Count
    'a1 copy to a5
    Range("a1").Copy Range("a5")
    '区域复制
    Range("a1:c10").Select
    Selection.Copy
    Range("d1").Select
    ActiveSheet.Paste
    [a1:b4].Value = Rnd() * 100
       xlRow = Application.Cells(Rows.Count, 1).End(xlUp).Row
    Debug.Print xlRow
    'select
    Worksheets("Sheet1").Activate
    numRows = Selection.Rows.Count
    numColumns = Selection.Columns.Count
    Selection.Resize(numRows + 1, numColumns + 1).Select
     'select no title
    Set tbl = ActiveCell.CurrentRegion
    tbl.Offset(1, 0).Resize(tbl.Rows.Count - 1, _
     tbl.Columns.Count).Select
     Range("b2").CurrentRegion.Select
End Sub

Sub ChangeInsertRows()
    '两行开始列数值不同是,插入一行
    Application.ScreenUpdating = False
    Dim xRow As Long
    For xRow = Application.Cells(Rows.Count, 1).End(xlUp).Row To 3 Step -1
        If Application.Cells(xRow, 1).Value <> Application.Cells(xRow - 1, 1).Value Then             Rows(xRow).Resize(1).Insert
    Next xRow
    
    Application.ScreenUpdating = True
End Sub
Sub adds()
    [a1:b10].Clear
    ActiveSheet.Range("a65536").End(xlUp).Offset(1, 0).Value = "张三"
End Sub

cnliutz

计算机基础教师

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注