Sorry the formatting in the previous post got mixed up. I am posting the problem again:

I have two excel spreadsheets.

The first one is Field ID and has all Field ID's associated with field names

<TABLE dir=ltr border=0 cellSpacing=0 cellPadding=2 width=353><TBODY><TR><TD bgColor=#333399 height=23 width="43%">

Field ID

</TD><TD bgColor=#333399 height=23 width="57%">

Field Name
</TD></TR><TR><TD height=23 width="43%">

1000

</TD><TD height=23 width="57%">

Field 1
</TD></TR><TR><TD height=23 width="43%">

1001

</TD><TD height=23 width="57%">

Field 2
</TD></TR><TR><TD height=23 width="43%">

1002

</TD><TD height=23 width="57%">

Field 3
</TD></TR><TR><TD height=23 width="43%">

1003

</TD><TD height=23 width="57%">

Field 4
</TD></TR><TR><TD height=23 width="43%">

1004

</TD><TD height=23 width="57%">

Field 5
</TD></TR><TR><TD height=23 width="43%">

1005

</TD><TD height=23 width="57%">

Field 6
</TD></TR></TBODY></TABLE>

The other spreadsheet is the Rules spreadsheet

<TABLE dir=ltr border=0 cellSpacing=0 cellPadding=2 width=379><TBODY><TR><TD bgColor=#333399 height=23 width="21%">

#

</TD><TD bgColor=#333399 height=23 width="79%">

Rule

</TD></TR><TR><TD height=93 width="21%">

1

</TD><TD height=93 width="79%">

IF** ‘Field 1’** <> BLANK

THEN

**‘Field 2’** = 0

</TD></TR><TR><TD height=93 width="21%">

2

</TD><TD height=93 width="79%">

IF **‘Field 3**’ = 0 AND **‘Field 4’** = 1

THEN

**‘Field 5’** = 9

</TD></TR></TBODY></TABLE>

Problem:

I want to write a macro that:

1. Can read rules from column Basic Rule in the Rules worksheet. The rules have field names in single quotes as would appear in when typed in microsoft word. They are not plain quote like '.

2. Go to the field worksheet and look for text e.g. Field 1 and get corresponding field id 1000

3. Come back on the Rules sheet and replace the field name with field id. Here is how the output should look like

<TABLE dir=ltr border=0 cellSpacing=0 cellPadding=2 width=313><TBODY><TR><TD bgColor=#333399 height=23>

Rule

</TD></TR><TR><TD height=93>

IF** ^1000** <> BLANK

THEN

**^1001** = 0

</TD></TR><TR><TD height=93>

IF **^1002** = 0 AND **^1003** = 1

THEN

**^1004** = 9

</TD></TR></TBODY></TABLE>

I have tried writing a find and replace macro but that does not work. I guess what I am looking for is some kind of pattern matching. Since I am a new to excel VBA I am having trouble with it. Any help will be much appreciated.