PDA

View Full Version : Exclude a word



Lartk
06-13-2013, 02:48 PM
Is there a way to get rid of the word "equity" in the below.

In cell A1, i have this: JPM US Equity

In cell B1, i would like to say = cell A1 - equity) - so the result would just be JPM US

Is that possible to write in a VBA code?

Lartk
06-13-2013, 02:49 PM
But I cant use the =right or left function because in each case the number of characters before the word equity differs..

GarysStudent
06-13-2013, 05:12 PM
How about:

Sub dural()
Range("B1").Value = Replace(Range("A1").Value, "equity", "")
End Sub

p45cal
06-13-2013, 05:18 PM
in b1:
=SUBSTITUTE(A1,"equity","")
you could also wrap it in TRIM:
=TRIM(SUBSTITUTE(A1,"equity",""))

snb
06-14-2013, 12:42 AM
You won't need VBA; use ctrl-H