Delete Specific Cell Content Based on Criteria

Barlew

New Member
Joined
May 10, 2011
Messages
7
Hello

I have about 1000 Spreadsheets that I’m working with, that all need their template updated. Using a combination of Macro Express and Excel VBA I’m nearly at a point where the update will be completely automated. The final piece of my jigsaw is as follows:

I need to delete some text from a specific cell. This cell might be in a slightly different reference in each of the 1000 sheets, BUT will always be adjacent to another cell containing unique text. SO what I need is VBA to:

  • Find the cell containing the text "Test description"
  • Look into the cell to the right of it
  • Find the characters " - " (that’s space dash space) in that cell
  • Then delete " - " and everything before it
There maybe more instances of " - " I’m only interested in the first " - " found.

Thanks
 
I missed the requirement for the "TS" needing to be in cell with the " - ". Here is my code (still a one-liner), modified to account for this (and presented as a normal macro)...
Code:
Sub FixCellContent()
  Cells.Find("Test description", , xlValues, xlWhole, , , False).Offset(, 1).Replace "*TS* - ", "", xlPart, , True
End Sub
 
Upvote 0

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,224,616
Messages
6,179,909
Members
452,949
Latest member
beartooth91

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