Here is a demo from the immediate window showing how to do it.
You only need the final command:
s = "SELECT Column1, Column2 From Mydb.Myspace.Mytable Where Column1 =
'Hello'"
? s
SELECT Column1, Column2 From Mydb.Myspace.Mytable Where Column1 = 'Hello'
? left(s,Instr(1,s,"Where",vbTextCompare)-1)
SELECT Column1, Column2 From Mydb.Myspace.Mytable
?
mid(s,instr(1,s,"From",vbTextCompare)+4,Instr(1,s,"Where",vbTextCompare)-(instr(1,s,"From",vbTextCompare)+4))
Mydb.Myspace.Mytable
--
Regards,
Tom Ogilvy
"douglascfast@hotmail.com" wrote:
> All,
>
> I am looking to rid myself of extra information in a column, and doing
> so in a Macro
>
> Here is what I have in column A
>
> SELECT Column1, Column2 From Mydb.Myspace.My table Where Column1 =
> 'Hello"
>
> I want to frind the FROM word (There is only one in the cell) and
> delete all to the Left including the from
>
> Then Find the WHERE (If it exsists) and delete all to the Right
> including the WHERE
>
> And I would end up with column A
>
> Mydb.Myspace.My table
>
> I have several examples of removing single char or commas from the
> column, but not entire words.
>
> Any ideas?
>
> Doug
>
>
Bookmarks