2013-11-05 2 views
0

열 B에서 "it"이라는 단어를 찾을 코드가 있습니다. 코드에서 찾으면 오른쪽의 셀을 다른 워크 시트에 복사합니다. 아무도 그것을 수정하는 방법을 알고 그래서 그것은 두 번째 "그것은"열 B에서 처음 읽지 않을까요? 당신이열에서 단어를 읽고 셀을 복사하십시오.

Dim rcell As Range 
Application.ScreenUpdating = False 
For Each rcell In Range("B2:B" & ActiveSheet.UsedRange.Rows.count + 1) 
If rcell.Value = "it" Then 
    rcell.Offset(, 1).Copy Sheets("another sheet").Range("C" & Rows.count).End(3)(2) 
    End If 
Next rcell 
Application.ScreenUpdating = True 
End Sub 
+1

"를하지 첫 번째 열에 B,?"을 "두 번째를 읽고" "그것"의 첫 번째 현상을 건너 뛰는 것을 의미합니까? 그렇다면 루프에 카운터를 추가하고 'Count'가> 2 인 경우 트리거 할 다른 'If'문을 추가하십시오. – L42

답변

0

이 시도 감사 : 당신에 의해 의미합니까 무엇

Dim rcell As Range 
Application.ScreenUpdating = False 
For Each rcell In Range("B2:B" & ActiveSheet.UsedRange.Rows.count + 1) 
Dim place% 
'find first instance of "it" 
place = InStr(1,rcell.Value, "it") 
If place <> 0 Then 
    'if there is one, check to see if there is a second instance 
    'line below may have to use place+1 instead of just place 
    If InStr(place,rcell.Value, "it") <> 0 Then 
     rcell.Offset(, 1).Copy Sheets("another sheet").Range("C" & Rows.count).End(3)(2) 
    End If 
End If 
Next rcell 
Application.ScreenUpdating = True 
End Sub 
관련 문제