将可见单元格从过滤表的几列复制到新插入的行

时间:2018-09-23 05:00:22

标签: cell

下面的代码工作正常。在A列中应用过滤器后,它允许我插入具有不同颜色的全新行(A到AJ列),同时,AH和G列是使用文本字符串生成的。我有一张2000行的表格(行数每天都在变化)。

但是我想在此现有宏中添加其他功能,但不知道如何添加。我将在下面进行解释。

在A列中应用了过滤器之后,我还需要将信息从S列中的最后一个活动可见单元复制到L列,并与AH和G列中的文本字符串一起粘贴到上述新插入的行中。

Sub insertRow()

    Dim rng As Range
    Dim rw As Long
    Dim lastrow As Long

    With ActiveCell
        rw = .Row
        .Offset(1).EntireRow.Insert
    End With

     Set rng = Rows(rw + 1)
     Thisrow = ActiveCell.Row

     Cells(Thisrow + 1, "AC").Value = "NO"  'extra text string
     Cells(Thisrow + 1, "AE").Value = "YES"  'extra text string



    rng.Columns("A:C").Interior.Color = RGB(191, 191, 191) 'color for the new row
    rng.Columns("D:E").Interior.Color = RGB(191, 191, 191) 'color for the new row
    rng.Columns("F:K").Interior.Color = RGB(255, 255, 0)   'color for the new row
    rng.Columns("L:R").Interior.Color = RGB(255, 128, 128) 'color for the new row
    rng.Columns("S:AG").Interior.Color = RGB(128, 0, 0)    'color for the new row



    Range("A" & rw, "AG" & rw + 1).Borders.Weight = xlThin  'range for the new row

End Sub

0 个答案:

没有答案