VBA to find specific text and cut and past into new worksheet.
Closed
DonalK
-
16 May 2017 à 08:57
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 22 May 2017 à 12:04
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 22 May 2017 à 12:04
Related:
- Cells text vba
- Vba find cell with specific text - Best answers
- Vba code to search for specific text - Best answers
- Vba find - Guide
- Vba case like - Guide
- Based on the cell values in cells b77 ✓ - Excel Forum
- Help me to add particular cells ✓ - Excel Forum
- Vba timer - Guide
2 responses
TrowaD
Posts
2921
Registration date
Sunday 12 September 2010
Status
Contributor
Last seen
27 December 2022
555
16 May 2017 à 11:49
16 May 2017 à 11:49
Hi DonalK,
I'm a little confused how many cells you want to cut.
First you say cut the cell with specific text and 2 or 3 cells below.
Then you say look at the cell below specific text and copy that cell (so the one below the specific text) and 2 or 3 cells below. That would mean; don't cut the specific text.
I went with the first one.
Give this code a try:
Best regards,
Trowa
I'm a little confused how many cells you want to cut.
First you say cut the cell with specific text and 2 or 3 cells below.
Then you say look at the cell below specific text and copy that cell (so the one below the specific text) and 2 or 3 cells below. That would mean; don't cut the specific text.
I went with the first one.
Give this code a try:
Sub RunMe()
Dim mFind As Range
Set mFind = Columns("A").Find("Technical date of entry")
If mFind Is Nothing Then
MsgBox "There is no cell found with the text 'Technical date of " _
& "entry' in column A of the active sheet."
Exit Sub
End If
If IsDate(mFind.Offset(1, 0)) = True Then
Range(mFind, Cells(mFind.Row + 2, "A")).Cut
Sheets("Sheet1").Select
Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
ElseIf WorksheetFunction.IsNumber(mFind.Offset(1, 0)) = True Then
Range(mFind, Cells(mFind.Row + 3, "A")).Cut
Sheets("Sheet1").Select
Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
End Sub
Best regards,
Trowa
22 May 2017 à 08:59
Thanks for coming back to me, I have a spread sheet that includes entries like the below, ideally I would like a code to find Technical entry date, if the line below Is a number it would cut row the tech entry row and the next 3 rows below and paste into the next sheet, it the line below the tech entry date is a date I need it to cut the tech entry date and the 2 lines below and paste into the next sheet, I also need this to loop through so that they are all removed from sheet 1 and pasted into sheet 2. Hope that makes sense.
Thank you,
Technical entry date
0011111 Ms Joe Blogs
11/2016 ( 01.11.2016 - 30.11.2016 )
IENDD
Technical entry date
12/2016 ( 01.12.2016 - 31.12.2016 )
IENDD