Remove certain string characters from the column

Razor_Rob

Board Regular
Joined
Aug 18, 2022
Messages
63
Office Version
  1. 365
Platform
  1. Windows
Hi
I have a VBA code that removes certain numbers at the end of the string in Column X
X
Test Date (12345678)
Sample Text (ABC12345)
Description Again (ARA30123)
Plumbing
Roof Plumbing

VBA Code:
With wsDest.Range("X3:X" & lDestLastRow)
        .Value = Evaluate("=IF({1},MID(" & .Address(0, 0, 1, 1) & ",1,LEN(" & .Address(0, 0, 1, 1) & ")-11))")
    End With

after running the code
X
Test Date
Sample Text
Description
#VALUE!
Ro

What I want to do is just remove the characters in the brackets including the brackets.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
That didnt work, its now not removing the characters, old data = the new data
 
Upvote 0
That didnt work, its now not removing the characters, old data = the new data
Are you sure you are not having the same issue you had in this thread ?
Error 1004 - Method Range of Object Worksheet failed

I tested @kevin9999's code and it worked fine for me but if you have not set a value for lDestLastRow (which was the issue in the above thread), then clearly it is not going to work.

PS: You might need to put a space before the bracket " (*)" using your sample data it is leaving a trailing space.

20220919 VBA Replace text in brackets Razor_Rob.xlsm
XYZAA
1
2Result after running macroWhat it looked like before
3Test Date Test Date (12345678)
4Sample Text Sample Text (ABC12345)
5Description Again Description Again (ARA30123)
6PlumbingPlumbing
7Roof PlumbingRoof Plumbing
8
Sheet1
 
Last edited:
Upvote 0
Assuming that the same mistake has not been made, my guess is that the Find/Replace has a carry-over 'Match entire cell contents' in place.
Try this instead

Rich (BB code):
With wsDest.Range("X3:X" & lDestLastRow)
  .Replace What:=" (*)", Replacement:="", LookAt:=xlPart
End With
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,255
Members
449,075
Latest member
staticfluids

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