VBA - find cells in column with a parantheses and display value

john69

New Member
Joined
Dec 19, 2010
Messages
11
Hello all:

I have a column of data where some cells will contain alphanumeric strings and others that will contain alphanumeric strings with a parentheses, number, close parentheses (e.g. Cells F3:F10 could have "E0001", 2, 3, etc) and F11 could have "E0012 (36)".
When a cell has no (), then I want a different cell in same row to display the number one ("1"). If the cell does contain a parantheses, then I want to display the value inside the parantheses.

I have found a way to do it as a formula, =IF(ISERROR(FIND("(",F88)),1,MID(F88,(SEARCH("(",F88)+1),((SEARCH(")",F88)-(SEARCH("(",F88)+1))))), but I want to incorporate it into an already created block of code.

Thank you in advance for your consideration in helping me with my little dilema!:)
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Where is it going in this block of code? Is there an existing loop? You can always just use the formula you already have in the code.

Code:
Sub findParent()

    'RC[-2] puts the formula at H
    'RC[-3] puts the formula at I
    'etc etc


    With Range("H1:H4")
        .FormulaR1C1 = "=IFERROR(MID(RC[-2],FIND(""("",RC[-2])+1,FIND("")"",RC[-2])-FIND(""("",RC[-2])-1),1)"
        .Value = .Value
    End With


End Sub
 
Upvote 0

Forum statistics

Threads
1,215,268
Messages
6,123,966
Members
449,137
Latest member
yeti1016

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