How to delete particular value in a cell without deleting existing data using find option

Natsha

New Member
Joined
May 20, 2021
Messages
44
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
  5. 2011
  6. 2010
  7. 2007
Platform
  1. Windows
I need an macro to delete the value which I find ...Example , I have data in coloum A and B, with header and data start in A2 and B2 and extend .
Starting from column B2 ,I have values like 1-6;3-8;12-6 ..etc. I eed an macro where I can remove particular value I type in textbox by find option and deleted it with deleting other data in the cella
Example B2 has 1-6;3-8;12-6;9-9 ,I want to remove ;9-9, after I paste the value in textbox it should remove ;9-9 and change into 1-6;3-8;12-6;

I Need macro where I can select the cells that datas need to be removed. Column B is the default column containing datas

Note: The value I need to delete changes everytime like, ;1-1 or 8-9; or 12-13;

kindly help.
 
Sorry, actually it could be simpler:
VBA Code:
Sub a1183689b()

Dim c As Range

    svar = Application.InputBox("Insert keyword:", Title, Type:=2)
  
    If svar = False Or svar = "" Then Exit Sub 'if user cancel
    Selection.Replace What:=svar, Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, _
    MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False

End Sub
Both works perfectly....thank you so much...I been struggling for few days trying everything I could do to get it... ???
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
You're welcome, glad to help & thanks for the feedback.:)
 
Upvote 0
To make it clear,
Unfortunately your reply did not make it clear for me as you did not address my specific examples.
Of course I know nothing about what your data could actually be but suppose a cell contained
1-6;3-8;12-6;9-9;2-6;3-6
and 2-6 is entered into the input box of the suggested code (from the accepted answer), the result is
1-6;3-8;1;9-9;;3-6
This leaves a "1" by itself. The code has removed 2-6 from 12-6 and left the 1. Is that what you want?
The code also leaves a double semicolon which from your first post you seemed to be trying to avoid. Did I mis-read that intention?
 
Upvote 0
Unfortunately your reply did not make it clear for me as you did not address my specific examples.
Of course I know nothing about what your data could actually be but suppose a cell contained
1-6;3-8;12-6;9-9;2-6;3-6
and 2-6 is entered into the input box of the suggested code (from the accepted answer), the result is
1-6;3-8;1;9-9;;3-6
This leaves a "1" by itself. The code has removed 2-6 from 12-6 and left the 1. Is that what you want?
The code also leaves a double semicolon which from your first post you seemed to be trying to avoid. Did I mis-read that intention?
When I remove I will not remove 2-6 instead I will remove 12-6; ...when I paste 12-6; this in textbook it will get removed...the solution has been given above
 
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

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