 




<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Need loop to cut rows that meet criteria and paste to another sheet.</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/need-loop-to-cut-rows-that-meet-criteria-and-paste-to-another-sheet/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/need-loop-to-cut-rows-that-meet-criteria-and-paste-to-another-sheet/</link>
	<description></description>
	<lastBuildDate>Sun, 19 May 2013 03:14:28 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: darraca</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/need-loop-to-cut-rows-that-meet-criteria-and-paste-to-another-sheet/#comment-74465</link>
		<dc:creator>darraca</dc:creator>
		<pubDate>Wed, 03 Mar 2010 09:04:06 +0000</pubDate>
		<guid isPermaLink="false">#comment-74465</guid>
		<description><![CDATA[No problem, glad it helped :)]]></description>
		<content:encoded><![CDATA[<p>No problem, glad it helped <img src='http://itknowledgeexchange.techtarget.com/itanswers/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mdsc</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/need-loop-to-cut-rows-that-meet-criteria-and-paste-to-another-sheet/#comment-74427</link>
		<dc:creator>mdsc</dc:creator>
		<pubDate>Tue, 02 Mar 2010 12:17:56 +0000</pubDate>
		<guid isPermaLink="false">#comment-74427</guid>
		<description><![CDATA[That worked great, thanks for your help.
MDS]]></description>
		<content:encoded><![CDATA[<p>That worked great, thanks for your help.<br />
MDS</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: darraca</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/need-loop-to-cut-rows-that-meet-criteria-and-paste-to-another-sheet/#comment-74305</link>
		<dc:creator>darraca</dc:creator>
		<pubDate>Thu, 25 Feb 2010 23:37:19 +0000</pubDate>
		<guid isPermaLink="false">#comment-74305</guid>
		<description><![CDATA[try this:
&lt;pre&gt;
Option Explicit

Private Sub CheckRows()

    Dim sCurrentText As String
    Dim sPreviousText As String
    Dim Counter As Long
    
    On Error GoTo ErrHandler
    
    Range(&quot;A1&quot;).Select
    Counter = 2
    Do Until ActiveCell.Text = &quot;&quot;
        sPreviousText = FirstFourWords(Trim(Range(&quot;A&quot; &amp; Counter - 1)))
        sCurrentText = FirstFourWords(Trim(Range(&quot;A&quot; &amp; Counter)))
        If Not sCurrentText = &quot;NOT LONG ENOUGH&quot; Then
            If sCurrentText = sPreviousText Then
                CutRowToNextSheet (Counter)
                Counter = Counter - 1
            End If
        End If
        Counter = Counter + 1
        ActiveCell.Offset(1, 0).Activate
    Loop
        
Finish:
    On Error GoTo 0
    Exit Sub
ErrHandler:
    MsgBox &quot;Error: &quot; &amp; Err.Description &amp; &quot; (&quot; &amp; Err.Number &amp; &quot;)&quot;
    Resume Finish
    Resume
End Sub

Private Function FirstFourWords(sCellText As String) As String
    
    Dim iCounter As Integer
    Dim iSpaces As Integer
    On Error GoTo ErrHandler
    
    iSpaces = 0
    
    If sCellText = &quot;&quot; Then
        FirstFourWords = &quot;NO TEXT&quot;
        GoTo Finish
    End If
    
    For iCounter = 1 To Len(sCellText)
        If Mid(sCellText, iCounter, 1) = &quot; &quot; Then
            iSpaces = iSpaces + 1
            If iSpaces = 4 Then
                FirstFourWords = Trim(Left(sCellText, iCounter - 1))
                Exit For
            End If
        End If
        FirstFourWords = &quot;NOT LONG ENOUGH&quot;
    Next iCounter
    
Finish:
    On Error GoTo 0
    Exit Function
ErrHandler:
    MsgBox &quot;Error: &quot; &amp; Err.Description &amp; &quot; (&quot; &amp; Err.Number &amp; &quot;)&quot;
    Resume Finish
    Resume
End Function

Private Sub CutRowToNextSheet(ByVal RowNumber As Integer)
    On Error GoTo ErrH
        
    Rows(RowNumber).Select
    Selection.Cut
    Sheets(&quot;Sheet2&quot;).Select
    Sheets(&quot;Sheet2&quot;).Range(&quot;A1&quot;).Select
    Do Until ActiveCell.Text = &quot;&quot;
        ActiveCell.Offset(1, 0).Activate
    Loop
    ActiveSheet.Paste
    Sheets(&quot;Sheet1&quot;).Select
    Selection.Delete Shift:=xlUp
    
Finish:
    On Error GoTo 0
    Exit Sub
ErrHandler:
    MsgBox &quot;Error: &quot; &amp; Err.Description &amp; &quot; (&quot; &amp; Err.Number &amp; &quot;)&quot;
    Resume Finish
    Resume
End Sub
&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>try this:</p>
<pre>
Option Explicit

Private Sub CheckRows()

    Dim sCurrentText As String
    Dim sPreviousText As String
    Dim Counter As Long
    
    On Error GoTo ErrHandler
    
    Range("A1").Select
    Counter = 2
    Do Until ActiveCell.Text = ""
        sPreviousText = FirstFourWords(Trim(Range("A" &amp; Counter - 1)))
        sCurrentText = FirstFourWords(Trim(Range("A" &amp; Counter)))
        If Not sCurrentText = "NOT LONG ENOUGH" Then
            If sCurrentText = sPreviousText Then
                CutRowToNextSheet (Counter)
                Counter = Counter - 1
            End If
        End If
        Counter = Counter + 1
        ActiveCell.Offset(1, 0).Activate
    Loop
        
Finish:
    On Error GoTo 0
    Exit Sub
ErrHandler:
    MsgBox "Error: " &amp; Err.Description &amp; " (" &amp; Err.Number &amp; ")"
    Resume Finish
    Resume
End Sub

Private Function FirstFourWords(sCellText As String) As String
    
    Dim iCounter As Integer
    Dim iSpaces As Integer
    On Error GoTo ErrHandler
    
    iSpaces = 0
    
    If sCellText = "" Then
        FirstFourWords = "NO TEXT"
        GoTo Finish
    End If
    
    For iCounter = 1 To Len(sCellText)
        If Mid(sCellText, iCounter, 1) = " " Then
            iSpaces = iSpaces + 1
            If iSpaces = 4 Then
                FirstFourWords = Trim(Left(sCellText, iCounter - 1))
                Exit For
            End If
        End If
        FirstFourWords = "NOT LONG ENOUGH"
    Next iCounter
    
Finish:
    On Error GoTo 0
    Exit Function
ErrHandler:
    MsgBox "Error: " &amp; Err.Description &amp; " (" &amp; Err.Number &amp; ")"
    Resume Finish
    Resume
End Function

Private Sub CutRowToNextSheet(ByVal RowNumber As Integer)
    On Error GoTo ErrH
        
    Rows(RowNumber).Select
    Selection.Cut
    Sheets("Sheet2").Select
    Sheets("Sheet2").Range("A1").Select
    Do Until ActiveCell.Text = ""
        ActiveCell.Offset(1, 0).Activate
    Loop
    ActiveSheet.Paste
    Sheets("Sheet1").Select
    Selection.Delete Shift:=xlUp
    
Finish:
    On Error GoTo 0
    Exit Sub
ErrHandler:
    MsgBox "Error: " &amp; Err.Description &amp; " (" &amp; Err.Number &amp; ")"
    Resume Finish
    Resume
End Sub
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: mdsc</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/need-loop-to-cut-rows-that-meet-criteria-and-paste-to-another-sheet/#comment-74274</link>
		<dc:creator>mdsc</dc:creator>
		<pubDate>Thu, 25 Feb 2010 15:47:49 +0000</pubDate>
		<guid isPermaLink="false">#comment-74274</guid>
		<description><![CDATA[If the first four words match the first four wordsof the row below.
Thanks,
MDS]]></description>
		<content:encoded><![CDATA[<p>If the first four words match the first four wordsof the row below.<br />
Thanks,<br />
MDS</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 6/8 queries in 0.014 seconds using memcached
Object Caching 315/316 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-20 00:02:43 -->