Loop backwards for searching a string
Closed
abhimanyu
-
Jul 15, 2012 at 02:33 PM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Jul 17, 2012 at 10:05 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Jul 17, 2012 at 10:05 AM
Related:
- Loop backwards for searching a string
- How to search for a word on a page - Guide
- Game loop - Download - Android emulators
- Fruity loop download - Download - Musical production
- Vba select case string contains - Guide
- Safe searching setting - Guide
1 response
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Jul 17, 2012 at 10:05 AM
Jul 17, 2012 at 10:05 AM
Hi Abhimanyu,
If I understand you correctly the following should work:
Best regards,
Trowa
If I understand you correctly the following should work:
Sub MoveData() Dim lRow, lRow2, x As Integer Dim SV As String lRow = Sheets("Sheet1").Range("C" & Rows.Count).End(xlUp).Row lRow2 = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Row SV = InputBox("Please input search value:") Sheets("Sheet1").Select For Each cell In Range("C2:C" & lRow) x = 1 Do x = x - 1 If cell.Value = SV And cell.Offset(x, -1).Value <> vbNullString Then cell.Offset(x, 0).EntireRow.Copy Destination:=Sheets("Sheet2").Range("A" & lRow2) Exit Sub End If Loop Until cell.Offset(x, 0).Row = 1 Next cell End Sub
Best regards,
Trowa