Created
February 4, 2014 05:48
-
-
Save r-plus/8798721 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub findCell2RowCopy() | |
Dim findString As Variant | |
Dim firstAddress As String | |
Dim findResultCell As Range | |
Dim oldSheet As Worksheet | |
Dim destinationSheet As Worksheet | |
Dim destinationRowNumber As Long | |
Set oldSheet = activeSheet | |
destinationRowNumber = 1 | |
findString = Application.InputBox("input find string", Type:=2) | |
If VarType(findString) = vbBoolean Or findString = "" Then | |
Exit Sub | |
End If | |
Set findResultCell = Cells.Find(findString, , xlValues, xlWhole) | |
If Not findResultCell Is Nothing Then | |
firstAddress = findResultCell.Address | |
Set destinationSheet = Worksheets.Add() | |
oldSheet.Activate | |
Do | |
Rows(findResultCell.Row).Copy destinationSheet.Rows(destinationRowNumber) | |
Set findResultCell = Cells.FindNext(findResultCell) | |
destinationRowNumber = destinationRowNumber + 1 | |
Loop Until findResultCell Is Nothing Or firstAddress = findResultCell.Address | |
End If | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment