Solved Microsoft Word Text Reversal

July 16, 2012 at 10:38:34
Specs: Windows XP
Hello All!

I am currently working in Microsoft Word on a large portion of genetic code, so it is a long series of letters. I am grabbing the code from an online database, copying it, and pasting it into Word. The work I am doing requires me to reverse the code I am copying over though. For example, I pasted in AAGAGGGAG from the database, but I want to have Word flip it around to read as GAGGGAGAA. Is there any way to do this without manually retyping everything? Some of the code sequences are thousands of characters long.


See More: Microsoft Word Text Reversal

Report •

July 16, 2012 at 11:56:53
✔ Best Answer
Well, I can do it in Excel. I'm sure that there is similar code for Word, but I don't how to write Word macros very well.

You could DAGS and see if any such code exists.

If you want to copy it all into Excel and then back into Word, this should work for you:

In the VBA editor, insert a Standard module.

Paste this User Defined Function (UDF) into the module:

Function RevGene(ByVal myGene As Range)
'Loop through the string in reverse order
  For myChar = Len(myGene) To 1 Step -1
'Build temporary string, character by character
    tempGene = tempGene & Mid(myGene, myChar, 1)
'Place reversed string in cell
 RevGene = tempGene
End Function

With your list starting in e.g. A1, enter this in B1 and drag it down:


The UDF will loop through each string in reverse order and build a reversed string.

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •
Related Solutions

Ask Question