The inverse of adding text....

rickblunt

Well-known Member
Joined
Feb 18, 2008
Messages
609
Office Version
  1. 2019
Platform
  1. Windows
Hello,
I tweaked one of my sub to add some text to a cell in a worksheet (the string for "Coding!F4"), this same code gets repeated on multiple items so F4 can ultimately end up with several text entries all in the same cell. I now realize that I also need to remove that text at some point - without deleting all of the other text in that cell. The inverse of what I am doing initially.

I am pretty sure that I can't simply tweak it to "ActiveCell.Value - " Scrubber 20 " instead of &. Is there another operator that will do this or is this going to require its own sub to do this?

I appreciate any input -thanks,

VBA Code:
Sub EnterNumber203()
 
    Sheets("Coding").Select
    Range("Coding!E4").Select
    ActiveCell.FormulaR1C1 = "3"
    Range("Coding!F4").Select
    ActiveCell.FormulaR1C1 = ActiveCell.Value & " Scrubber 20 "
    Sheets("Scrubber Schedule").Select
    Range("B4").Select
    
End Sub
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
How about
VBA Code:
    With Range("Coding!F4")
      .Value = Replace(.Value, " Scrubber 20 ", "")
    End With
 
Upvote 0
Solution
How about
VBA Code:
    With Range("Coding!F4")
      .Value = Replace(.Value, " Scrubber 20 ", "")
    End With
That worked perfect Fluff. So if I understand it properly, the code takes the value of "scrubber 20" and replaces it with "". I can think of a myriad of ways I am going to be tweaking some of my other WB's lol

Thank you for yet another coding lesson.
 
Upvote 0

Forum statistics

Threads
1,215,575
Messages
6,125,619
Members
449,240
Latest member
lynnfromHGT

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