2017-09-20 10 views
0

2つのExcelファイルがあります。 File_1とFile_2。 File_1には2枚あります。 Sheet_AとSheet_B。 File_2からのデータは、Sheet_1(File_1内)に転記されます。Excel VBAコピーシートオリジナルシートへのリンクなし

私は、シート_Aからシート_Bにデータをコピーするシート_BのボタンにVBAコードを添付しています。コードは正常に動作しますが、File_1からのリンクは保持されます。

データをコピーして、リンクを維持せずに書式を保持したいと思います。どうすればこれを達成できますか?

Sheet_BにSheet_Aからコピーしたデータは以下の通りです私のコードの一部:

' Check the Record Sheet to ensure the data is not already there 
    Set CheckForDups = recordSht.Range(recordSht.Cells(1, 1), recordSht.Cells(1, lCol)).Find(What:=maxCustomerRng.Offset(-1, 0).Value, LookIn:=xlValues) 

    ' If CheckForDups is Nothing then the date was not found on the record sheet. Therefore, copy the column 
    If CheckForDups Is Nothing Then maxCustomerRng.EntireColumn.Copy Before:=recordSht.Cells(1, lCol + 1) 
+0

テキストとコードの間には、状況が非常に不明です。 –

+0

@ScottHoltzman投稿を編集しました。今、それは意味をなさないと思う。 – aab

答えて

0

私はあなたが先に値を貼り付ける必要があると思う:

If CheckForDups Is Nothing Then 
    maxCustomerRng.EntireColumn.Copy 
    recordSht.Cells(1, lCol + 1).PasteSpecial xlPasteValues 
    recordSht.Cells(1, lCol + 1).PasteSpecial xlPasteFormats 
End If 

・ホープこのヘルプ。

+0

ありがとう、それは動作しますが、フォーマットを保持しません。 – aab

+0

'xlPasteValuesAndFormats' - 私は定数だと思います。または、もう一つ行 'recordSht.Cells(1、lCol + 1).PasteSpecial xlPasteFormats'を追加してください。 –

+0

@ScottHoltzmanが正しいです。 1行追加してください:recordSht.Cells(1、lCol + 1).PasteSpecial xlPasteFormats –

関連する問題