string replace question

ivill

New Member
Joined
Oct 3, 2021
Messages
37
Office Version
  1. 2019
Platform
  1. Windows
Hi, newbie here, AA111Q(BB222Q;CC0Q;DD0Q;EE333Q)
how do i replace the stuff in the bracket including 0Q
my expect result in the below:
AA111Q(BB222Q;EE333Q)
please help, thanks?
 
Glad you got an answer, but for my benefit can you explain that final result? That is, why is WOOD110Q left in when it contains "0Q"
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Glad you got an answer, but for my benefit can you explain that final result? That is, why is WOOD110Q left in when it contains "0Q"
You may have missed my edit to you in my last post to the OP. Here is what I wrote... I assumed it was because the number in front of the "Q" is not 0, it is 110.
 
Upvote 0
You may have missed my edit to you in my last post to the OP. Here is what I wrote... I assumed it was because the number in front of the "Q" is not 0, it is 110.
Yes, Rick, I had missed that edit. Thank you for the clarification. (y)

Just for completeness, the change to my UDF would be just 2 characters added

Rich (BB code):
Function Remove0Q(S As String) As String
  With CreateObject("VBScript.RegExp")
    .Global = True
    .Pattern = ";\w+?\D0Q(?=;|\))"
    Remove0Q = Replace(.Replace(Replace(S, "(", "(;", 1, 1), ""), "(;", "(", 1, 1)
  End With
End Function

ivill.xlsm
AC
1AA111Q(BB222Q;CC0Q;DD0Q;EE333Q)AA111Q(BB222Q;EE333Q)
2TOTAL111Q(PETER222Q;MIKE0Q;BILL0Q;LILLY333Q)TOTAL111Q(PETER222Q;LILLY333Q)
3TOTAL1110Q(KEN0Q;PETER222Q;MIKE0Q;BILL0Q;LILLY333Q;ANN0Q)TOTAL1110Q(PETER222Q;LILLY333Q)
4AA111Q(BB222Q;CC0Q;DD0Q;EE333Q)AA111Q(BB222Q;EE333Q)
5TOTAL111Q(PETER222Q;MIKE0Q;BILL0Q;LILLY333Q)TOTAL111Q(PETER222Q;LILLY333Q)
6TOTAL111Q(PETER222Q;BILL0Q;LILLY333Q;MIKE0Q)TOTAL111Q(PETER222Q;LILLY333Q)
7total110Q(ALICE55Q;JIM0Q;WOOD55Q)total110Q(ALICE55Q;WOOD55Q)
8total110Q(ALICE0Q;JIM0Q;WOOD110Q)total110Q(WOOD110Q)
Text Replacement
Cell Formulas
RangeFormula
C1:C8C1=Remove0Q(A1)
 
Upvote 0

Forum statistics

Threads
1,213,484
Messages
6,113,927
Members
448,533
Latest member
thietbibeboiwasaco

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