2013-08-07 2 views
-1

안녕하세요 제 코드는 (i, 1) 코드를 검색하여 "Hello"를 찾았지만 WSS로 전송하지 않을 때 더 많은 것을 얻을 수 있습니다. 누군가 도와주세요VBA 코딩 문제가 워크 시트에 추가하지 못했습니다.

Sub AddSelection() 

Dim WSD As Worksheet ' Sheet 1 as prices sheet 
Dim WSW As Worksheet ' Workings sheet as Information 
Dim WSS As Worksheet ' Selections worksheet 

Set WSD = Worksheets("Selection") 
Set WSW = Worksheets("Workings") 
Set WSS = Worksheets("Selections") 

' Loop through records on WSD column A 

FinalRow = WSD.Cells(Rows.Count, 1).End(xlUp).Row 
    For i = 5 To FinalRow 
     If WSD.Cells(i, 1) = "Hello" Then 


     ' When I run the code this where the problem is 
     WSD.Cells(i, 1).Copy Destination:=WSS.Cells(NextRow, 4) 


     NextRow = NextRow + 2 

     FinalRow = WSS.Cells(Rows.Count, 1).End(xlUp).Row 

    End If 
Next i 

'Make sure WSR is the active sheet 
WSS.Select 


' Report that the macro is done 
MsgBox prompt:=NextRow - 1 & " Results Records Are Copied To Worksheet." 


End Sub 

답변

4

NextRow가 정의되어 있지 않습니다. 그것을 사용하기 전에 정의해야합니다.

이 실수를 중지하여 VBA 프로젝트의 모든 "파일"의 상단에이를 작성하려면 :

Option Explicit

관련 문제