2016-06-16 4 views
1

한 시트의 마지막 행 (변수 위치)을 다른 시트의 변수 위치에있는 마지막 행에 복사하려고합니다. 지금까지 This solutionThis solution을 시도했습니다. 그들은 모두 초기 스프레드 시트 (WWData)의 정확한 마지막 행 대신 여러 행을 복사했습니다.변수 위치 마지막 행을 다른 시트로 복사 VBA

Sub copylastrow() 
Dim Last_Row1 As Long 
Dim Last_Row2 As Long 
Last_Row1 = WWData.Cells(Rows.Count, 1).End(xlUp).Row 
Last_Row2 = WWOutput.Cells(Rows.Count, 1).End(xlUp).Row + 1 
WWData.Cells(Last_Row1).Copy WWOutput.Cells(Last_Row2) 
End Sub 

내가 뭘 잘못하고 있니? 참고 : WWData 및 WWOutput은 이전에 정의 된 것입니다. 이 우연히 발견 누가 어떤 들어 조쉬

+0

'세포 (Last_Row1) .Copy'을'@findwindow : 행과 열을. 또한, 워크 시트로'Rows.Count'를 한정하십시오. – findwindow

+2

'WWData.Cells (Last_Row1) .Copy WWOutput.Cells (Last_Row2)'를'WWData.Rows (Last_Row1) .Copy WWOutput.Rows (Last_Row2)'로 변경해보십시오. –

+0

두 옵션 모두 훌륭하게 작동했습니다. 답변을 게시 하시겠습니까? –

답변

0

나중에 나는이 개 권고의 조합을 사용하여 끝났다. 적절한 스프레드 시트로 Rows.Count을 인증했습니다. 또한 마지막 줄에있는 .Cells.Rows으로 바꿨습니다.

종료 코드는 다음과 같습니다

Last_Row1 = WWData.Cells(WWData.Rows.Count, 1).End(xlUp).Row 
Last_Row2 = WWOutput.Cells(WWOutput.Rows.Count, 1).End(xlUp).Row + 1 
WWData.Rows(Last_Row1).Copy WWOutput.Rows(Last_Row2) 

큰이 @ScottCraner에게 감사와 2 인자가 필요 cells`

관련 문제