0

列 B で "it" という単語を探すコードがあります。コードが見つかった場合は、その右側のセルを別のワークシートにコピーします。最初の列ではなく、列Bの2番目の「それ」を読み取るように変更する方法を知っている人はいますか? ありがとうございました

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
4

1 に答える 1

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
于 2013-11-05T15:20:56.297 に答える