Keeping key words in row data and delete the rest of the rows Macro updating Please

mingandmong

Active Member
Joined
Oct 15, 2014
Messages
339
Good Afternoon
could someone please update my Macro below
it only keeps row data that contains data between ## ^^ **

i would like to replace with the following 3 unique data starting in A10 down

MON:
Data Sent
SURVEY:

many thanks
Code:
Sub DelRws_v2()
  Application.ScreenUpdating = False
  With Range("A10", Range("A" & Rows.Count).End(xlUp))
    .Replace What:="^^<*>", Replacement:="", LookAt:=xlPart
    .Replace What:="^^", Replacement:="##^^##", LookAt:=xlPart
    .AutoFilter Field:=1, Criteria1:="<>*##*##*", Operator:=xlAnd, Criteria2:="<>*~*~**~*~**"
    .Offset(1).EntireRow.Delete
    ActiveSheet.AutoFilterMode = False
    .Replace What:="##^^##", Replacement:="^^", LookAt:=xlPart
  End With
  Application.ScreenUpdating = True
End Sub
 
Last edited by a moderator:

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Yes it is Peter_SSs
its the same macro that you wrote for me i just need to delete the extra rows in my Data that contain any string with ^^> but not ^^
 
Upvote 0
First a few things not directly related to your question
  1. When posting code, please use code tags to preserve the formatting. My signature block below has more on that.
  2. For sample data and expected results it would be better if you could use XL2BB. Again see my signature.
  3. Please update your Account details. See signature.

i just need to delete the extra rows in my Data that contain any string with ^^> but not ^^
Did you mean this? ^^<


Try ..
VBA Code:
Sub keepRows_v2()
  Dim myVals As Variant, itm As Variant

  myVals = Split(": ##|^^|SURVEY:", "|")
  Application.ScreenUpdating = False
  With Range("A10", Range("A" & Rows.Count).End(xlUp))
    For Each itm In myVals
      .Replace What:=itm, Replacement:="%%%" & itm, LookAt:=xlPart, MatchCase:=False
    Next itm
    .Replace What:="%%%^^<", Replacement:="^^<", LookAt:=xlPart
    .AutoFilter Field:=1, Criteria1:="<>*%%%*"
    .Offset(1).EntireRow.Delete
    ActiveSheet.AutoFilterMode = False
    .Replace What:="%%%", Replacement:="", LookAt:=xlPart
  End With
  Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top