Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Can't get the right formula function.

Hi everyone,

I have text placed in A1 which is then I need to make some changes using
formula placed in A2. I've tried using Substitute and Replace but still
can't get the best result. Does it need a special functions to handle
formula? The table referrence located within range(A5:B11). The following
are an examples for these situations:-

A B
The quick brown fox jumps over the lazy dogs.
=The big fat cat jumps over the lazy monkeys.

fox cat
foxs cats
dog monkey
dogs monkeys
brown fat
quick big

Any help are appreciated.

Hopefully,
Jaemun.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Can't get the right formula function.

Hi,
Try this User Defined Function (UDF). It assumes original words in
column A (starting on or after column 2) and replacements column B.

in B1 put "=ReplaceWords(A1)"


HTH


Function ReplaceWords(ByVal MyText As String) As String

Dim FirstRow As Long, Lastrow As Long, i As Long
Dim wdRng As Range

FirstRow = Cells(2, "A").End(xlDown).Row
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set wdRng = Range(Cells(FirstRow, "A"), Cells(Lastrow, "B"))

For i = 1 To wdRng.Count Step 2
MyText = Replace(MyText, Trim(wdRng(i)), Trim(wdRng(i + 1)), 1)
Next i

ReplaceWords = MyText

End Function

"Jaemun" wrote:

Hi everyone,

I have text placed in A1 which is then I need to make some changes using
formula placed in A2. I've tried using Substitute and Replace but still
can't get the best result. Does it need a special functions to handle
formula? The table referrence located within range(A5:B11). The following
are an examples for these situations:-

A B
The quick brown fox jumps over the lazy dogs.
=The big fat cat jumps over the lazy monkeys.

fox cat
foxs cats
dog monkey
dogs monkeys
brown fat
quick big

Any help are appreciated.

Hopefully,
Jaemun.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Can't get the right formula function.

Hi Toppers,

Thank you. That was a nice one. It does handle the treate and works really
great!

Keep it up and wish you good luck. Cheer:)

Regards,
Jaemun.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function or formula to use yguan Excel Worksheet Functions 2 January 12th 09 10:59 AM
what function/formula do I use? kate Excel Worksheet Functions 2 May 29th 08 06:11 PM
Help with OR function in IF function formula veggies27 Excel Worksheet Functions 3 March 18th 08 10:04 PM
A formula/function to return a formula/function sith janitor Excel Worksheet Functions 4 September 22nd 06 05:01 PM
Max value in formula/function SEWINBABY Excel Worksheet Functions 3 January 19th 05 01:37 AM


All times are GMT +1. The time now is 04:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"