2014-01-18 4 views
0

이 코드가 있지만 수식을 복사하고 방금 값이 있습니다. VBA에 너무 익숙하지 않습니다.복사하여 붙여 넣기 값

Dim sh4 As Worksheet, sh5 As Worksheet, lr As Long, rng As Range 

Set sh4 = Sheets("Transfer_New") 
Set sh5 = Sheets("Closed_Loans") 
lr = sh4.Cells(Rows.Count, 1).End(xlUp).Row 
Set rng = sh4.Range("A2:A" & lr) 

Application.Cursor = xlHand 

iReply = MsgBox(Prompt:="Are you sure you want to transfer client to CLOSED_LOANS?", _ 
    Buttons:=vbYesNo, Title:="Document Production") 
     If iReply = vbYes Then 
      Application.Cursor = xlWait: rng.EntireRow.Copy sh5.Cells(Rows.Count, 1).End(xlUp)(2): Application.Cursor = xlNorthwestArrow      
     End If 
End Sub 

답변

0

변경이 : 여기에

If iReply = vbYes Then 
     Application.Cursor = xlWait: rng.EntireRow.Copy sh5.Cells(Rows.Count, 1).End(xlUp)(2): Application.Cursor = xlNorthwestArrow      
    End If 

(NO 정말 좋은 이유가 - 확실히 가독성/명확성을 위해 - 한 줄에 여러 줄의 코드를 넣어 (즉, 어떤 :입니다 세퍼레이터) 수행

If iReply = vbYes Then 
     Application.Cursor = xlWait 
     rng.EntireRow.Copy sh5.Cells(Rows.Count, 1).End(xlUp)(2) 
     Application.Cursor = xlNorthwestArrow      
    End If 
이어서이

로 변경합니다.

Dim destRng as Range 
    Set destRng = sh5.Cells(Rows.Count, 1).End(xlUp).Offset(1,0) 
    If iReply = vbYes Then 
     Application.Cursor = xlWait 
     destRng.Value = rng.Value 
     Application.Cursor = xlNorthwestArrow      
    End If 
,617 당신이 값을 붙여 넣을 경우
0

,이 시도 :

rng.Entirerow.Copy: sh5.Cells(Rows.Count, 1).End(xlUp).Offset(1,0).PasteSpecial xlPasteValues 

난 단지 코드에서 누락 무슨 그게 생각합니다.