VBA to find specific text and cut and past into new worksheet.
Closed
DonalK
-
May 16, 2017 at 08:57 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - May 22, 2017 at 12:04 PM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - May 22, 2017 at 12:04 PM
Related:
- Vba select cell with specific text
- Vba find cell with specific text - Best answers
- Excel vba find all cells with specific text - Best answers
- Vba select case like - Guide
- Excel conditional formatting if cell contains specific text - Excel Forum
- To create a network bridge you must select at least two lan ✓ - Network Forum
- How to find specific words on a page - Guide
- Excel conditional formatting if another cell contains specific text ✓ - Excel Forum
2 responses
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
May 16, 2017 at 11:49 AM
May 16, 2017 at 11:49 AM
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
May 22, 2017 at 08:59 AM
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