Reverse Text then combine rows

D

darnoldman

I need to create passwords for new users as they come aboard. The passwords
must be 8 characters. I have a workbook with cells containing their last name
and first name. What I need is a new column which will take the last 6
characters of the last name in reverse (ex. Johnson-->nosnho), combine these
6 characters with the last 2 characters of the first name in reverse (ex.
Charles --> se). The final result for the password in this example would be
nosnhose. What will happen if the last name and first name contain less than
8 characters (ex. Jen Lee)?
 
R

ryguy7272

I don't know of an easier way to do it, but this seems to work:

Function ReverseText(cell)
ReverseText = StrReverse(cell.Text)
End Function

A1=Charles
B1=Johnson

C1=RIGHT(reversetext(B1),6)
D1=RIGHT(reversetext(A1),2)


Regards,
Ryan---
 
D

darnoldman

Okay, so as I understand your instructions, in A1, I have Charles. In B1, I
have Johnson. In C1, I type =RIGHT(reversetext(B1),6) and in D1, I type
=RIGHT(reversetext(A1),2). Then I drag down the formulas from C1 & D1 several
rows. Next, in A2, I type another first name and in B2, another last name,
but the formula function does nothing. Cells C2 & D2 remain empty. I have
tried the formula with and without the =, but it does not matter. I'm sure I
am doing something wrong, but do not know what it could be. Suggestions?
 
R

ryguy7272

Ok, view this web site:
http://www.anthony-vba.kefra.com/vba/vbabasic1.htm#Creating_Your_First_Macro

Folow steps 1-3, and in step 3, paste the 3 lines below:
Function ReverseText(cell)
ReverseText = StrReverse(cell.Text)
End Function

This is your function. Go back to the spreadsheet and call the function
like this:
=RIGHT(reversetext(B1),6) ...this is copied from here and pasted into cell C1
=RIGHT(reversetext(A1),2) ...this is copied from here and pasted into cell D1


That should work for you. If it does work, please indicate so by clicking
the 'Yes' button next to 'Was this post helpful to you?' Write back if you
have more questions.


Regards,
Ryan---
 
D

darnoldman

Perfect, Ryan. Thanks so much. The difference was the VBA script. I had not
done thast before.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top