2016-04-11 19 views
0

私は他人からの提案がありましたが、私の要求に完全に一致しません。私が必要とするのは、これらのデータを「貼り付け」ではなく、別のワークシートに「INSERT」することです。これは、「貼り付け」を使用すると以前のデータが上書きされるためです。MS Excelボタンコピー挿入&削除

以下はコーディングですが、「貼り付け」を「挿入」に変更するのに役立ちますか?何度も試してみた。

Private Sub All_Click() 

    With Worksheets("Sheet1") 
    'turn off AutoFilter if it is on 
    If .AutoFilterMode Then .AutoFilterMode = False 
    'set a CF rule for <Now 
    With .Range(.Cells(2, "L"), .Cells(Rows.Count, "L").End(xlUp)) 
    .FormatConditions.Delete 
    With .FormatConditions.Add(Type:=xlExpression,Formula1:="=$L2<NOW()") 
    .Font.Color = vbRed 
    End With 
    End With 
    'add an AutoFilter for red font cells 
    With .Range(.Cells(1, "L"), .Cells(Rows.Count, "L").End(xlUp)) 
     .AutoFilter Field:=1, Criteria1:=vbRed, _ 
        Operator:=xlFilterFontColor 
    End With 
    'deal with the red font cells 
    With .Range(.Cells(2, "L"), .Cells(Rows.Count, "L").End(xlUp)) 
     If CBool(Application.Subtotal(103, .Cells)) Then 
      With .SpecialCells(xlCellTypeVisible) 
       'select them (there are better ways to get things done) 
       '.Select 
       'copy them to sheet2 (do not need Select for this) 
       .EntireRow.Copy Destination:=Sheet2.Range("A4").Rows("1:1") 
       'delete them 
       .EntireRow.Delete 
      End With 
     End If 
    End With 
    'turn off AutoFilter 
    If .AutoFilterMode Then .AutoFilterMode = False 
End With 

End Sub 

答えて

0

あなたがSheet2の上の既存のデータの後にそれらを貼り付けたい場合は、あなたがそのシート上の最後の行を見つけ、その行と目的地を設定する必要があります+ 1

+0

最後の行が最後ですExcelワークシート... – Han

関連する問題