2017-09-20 1 views
0

두 개의 Excel 파일이 있습니다. File_1 및 File_2. File_1에는 두 개의 시트가 있습니다. Sheet_A 및 Sheet_B. File_2의 데이터는 Sheet_A로 바뀝니다 (File_1에 있음).Excel VBA 원본 시트에 대한 링크가없는 시트 복사

Sheet_B의 단추를 Sheet_B의 Sheet_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이 맞습니다. 한 줄을 추가하십시오 : recordSht.Cells (1, lCol + 1) .PasteSpecial xlPasteFormats –

관련 문제