nevsky092315
New Member
- Joined
- May 3, 2020
- Messages
- 7
- Office Version
- 365
- Platform
- Windows
Hello,
I am trying to build a macro for the following condition:
Find the cell in column A that has Text A and delete all rows until that cell and then find Text B and delete all rows until the next Text A
and again find the next Text B and so on... this loop needs to repeat for minimum of 4 iterations to maximum of 12 iterations.
Sub FindTextAB()
Find_TextA
Find_TextB
End Sub
--------------------------------------------
Sub Find_TextA()
Do Until ActiveCell.Value = "TextA"
Selection.EntireRow.Delete --->This loop is where I am facing error, macro freezes and it doesn't come out of the loop once there is no data in below cells)
Loop
End Sub
----------------------------------------------
Sub Find_TextB()
Cells.Find(What:="TextB", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
End Sub
----------------------------------------------
Your help is greatly appreciated.
Thank you,
Nevsky
I am trying to build a macro for the following condition:
Find the cell in column A that has Text A and delete all rows until that cell and then find Text B and delete all rows until the next Text A
and again find the next Text B and so on... this loop needs to repeat for minimum of 4 iterations to maximum of 12 iterations.
Sub FindTextAB()
Find_TextA
Find_TextB
End Sub
--------------------------------------------
Sub Find_TextA()
Do Until ActiveCell.Value = "TextA"
Selection.EntireRow.Delete --->This loop is where I am facing error, macro freezes and it doesn't come out of the loop once there is no data in below cells)
Loop
End Sub
----------------------------------------------
Sub Find_TextB()
Cells.Find(What:="TextB", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
End Sub
----------------------------------------------
Your help is greatly appreciated.
Thank you,
Nevsky