View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Plica05 Plica05 is offline
external usenet poster
 
Posts: 1
Default A Macro to replace a string in a cell with a string from another cell???


Hi there,

I am trying to write a subroutine Macro that replaces the string "xx
in Column C with the value from the neighbouring Column D.

Column C Column D
-------------------------------- -----------
Overpayment of xx from July 2005 -228.18
Credit Note for xx from Jan 2003 -121.90
Write Off of xx from Oct 2002 -238.24
Overpayment of xx from June 2003 -33.88
Overpayment of xx from Dec 2004 -153.63
Write Off of xx from April 2001 -195.15


For instance, the first entry in Column C above should be:

"Overpayment of -228.18 from July 2005"

This shouldn't be very hard to do I know!

I've tried using the REPLACE() and Find() and search() methods bu
whenever I run the Macro it says "Subroutine or Function not defined".

I guess I need to start by finding the numerical position of the "xx
substring in the text contents of each cell (from column C) and the
use this info with the replace method or something?

I've scoured the web and there's surprisingly little sample code whic
shows how to replace strings with other strings using VBA!

I'd be very grateful for any help you guys can offer!!

Sea

--
Plica0
-----------------------------------------------------------------------
Plica05's Profile: http://www.excelforum.com/member.php...fo&userid=2631
View this thread: http://www.excelforum.com/showthread.php?threadid=39584