Article View: comp.apps.spreadsheets
Article #209Excel macro help! !pleh orcam lecxE
From: Darryl 'Well
Date: Fri, 06 Nov 1992 10:21
Date: Fri, 06 Nov 1992 10:21
64 lines
2734 bytes
2734 bytes
hey Excel studs and studettes--here's a puzzler for y'all...
once upon a time, in Excel 3.0, i wrote a macro that let me "flip"
text around so that it would read backwards. e.g. a cell with the
following formula:
=flipit("hello there")
would result in "ereht olleh"
the reason i wanted to do this is so that i could extract the last
word of a string. So the trick was, flip the text around, find the
first word (all the characters up to a space), then flip the text back
around. All this trouble because the find command isn't able to start
at a certain location and work it's way back.
somewhere between then and now, i lost the aforementioned macro.
it may sound like a pain, but it helps when you're doing data entry.
Instead of having to key in a separate Title (Mr.), First Name,
(Darryl), and Last Name (Lee), you can simply type "Mr. Darryl Lee",
and then derive the following:
a last name (to do sorts upon), and...
a salutation, (like "Mr. Lee")
ANYWAYS, right nowm, my macro looks like this:
A1 flipit
A2 =ARGUMENT("tex",2)
A3 =FOR("count",1,LEN(tex),1)
A4 =count
A5 =(LEN(tex)+1)-count
A6 =REPLACE(tex,count,1,MID(tex,(LEN(tex)+1)-count,1))
A7 =NEXT()
A8 =tex
A9 =RETURN(A6)
(cells a4, and a8, are strictly for debugging purposes, unless you can
think of a better use for them)
but what i get when i type:
=flipit("hello there")
is:
hello therh
if you display values on the macro sheet when this is running, and
give it a really long test, like "hello there everyone in Texas",
you'll see cell A6 run through and replace every letter, but after
each replacement it begins anew with the untouched string. obviously
i need a temporary variable, but in function macros, the formula
function isn't allowed.
For the life of me i can't figure out how i did it before. if you can
help, or even find a better way to do it, i'd love to hear from you.
thanks for your time. please e-mail a response to:
--
-------------------------------cut here--------------------------------------
"Girls are like parking spaces--all the good ones are already taken" --Anlo Liu
"Everywhere I go, it seems to say `no parking'" --Jimmy Yu
Darryl Lee, UC Santa Barbara udarryl@mcl.ucsb.edu
Technical Details
Message-ID:
<udarryl.721045294@mcl>Path:
arc1-ca.pugleaf.net!sparky!uunet!usc!news.service.uci.edu!network.ucsd.edu!ucsbcsl!mcl!udarrylShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!news.service.uci.edu!network.ucsd.edu!ucsbcsl!mcl!udarryl From: udarryl@mcl.ucsb.edu (Darryl 'Well) Newsgroups: comp.apps.spreadsheets Subject: Excel macro help! !pleh orcam lecxE Summary: Please help me write a macro to flip text around... Keywords: macro flip excel help writing stupid Message-ID: <udarryl.721045294@mcl> Date: 6 Nov 92 10:21:34 GMT Sender: root@ucsbcsl.ucsb.edu Lines: 64