Find and replace text in part of field

lefty38

Board Regular
Joined
Oct 27, 2005
Messages
85
I am looking for some code for a macro
that will remove the "RC" off of the Course code

example data
11112345RC
12121231
sdswe2323RC

Desired results
11112345
12121231
sdswe2323


more info
Find What: tblEnrollments.[Course Code] = "RC"
Replace With : tblEnrollments.[Course Code] = ""
Look in : tblEnrollments.[Course Code]
Match: Anypart of field
Search All
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
thank you Bob

it works as a query -
but when i call it from a macro using the RunSQL Command
on the macro action line

SQL Statement:
Replace(tblEnrollments![Course Code],"RC","") AS Expr1
FROM tblEnrollments;

Use transaction = Yes


it errors:
A runSQL action requires an argument consisting of an SQL statement.
for Example, an action query that appends records starts with INSERT INTO. A data-definition query that creates a table starts with create table.

I am not sure how else to call a quey inside of a macro other than use
runsql
 
Upvote 0
I have a macro that empties a table and imports new data from a large excel file
then (hopefully) removes the "RC" from the end of the [tblEnrollments]![Course Code]
So I can join [tblEnrollments]![Course Code] with other tables for other queries
 
Upvote 0
My suggestion - is just create an update query you can call once the import has been completed and then call it from the macro.
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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