2017-03-22 6 views
-2

コピーした行を同じ既存のデータに挿入するには、以下のコードでコピーした行を既存のデータと同じシートに挿入したいコピーされた表示行を上から元のデータに挿入する方法

Name Location Salary 
Sy  Hyd   12,000 
Ay  Hyd   13,000 
Raju Hyd   15,000 
私はテーブルの上から名前の場所と給与をコピーして(ヘッダーの下)上から上記と同じテーブルにコピーされたデータを挿入したい

Sub Referral() 

Application.ScreenUpdating = False 

With Sheets("Sheet3") 

    'this is generic, you may need to adjust this based on your sheet and data needs 
    Intersect(.UsedRange, .UsedRange.Offset(1)).SpecialCells(xlCellTypeVisible).Copy 

End With 

'goes to cell below last used cell in column A 
Sheets("Sheet4").Cells(Rows.Count, 1).End(xlUp).Offset(1).PasteSpecial xlPasteValues 


Application.ScreenUpdating = True 'don't forget to turn on your ScreenUpdating again! 

End Sub 
+0

正確に何をしたいのか分かりません。さらに、あなたが他の場所から取得したコードは、すでにあなたが望むことを行うのに十分なだけです。ちょうどコードを理解しようとすると、私はあなたのニーズに合わせてビットを少し変更しなければならないと確信しています... – JiheL

+0

JiheLに返信してくれてありがとう、私の要件は何iamコピー、同じデータを上から –

答えて

0

私はちょうどあなたのコードを取り、いくつかのものを変更し

Sub Referral() 

Application.ScreenUpdating = False 

With Activesheet 
    .range(.cells(2,1),.cells(.cells(.rows.count,1).end(xlup).row,.cells(1,.columns.count).end(xltoleft).column)).Copy 
    .Cells(2, 1).PasteSpecial xlPasteValues 
End With 

Application.ScreenUpdating = True 

End Sub 
関連する問題