Thread View: comp.apps.spreadsheets
2 messages
2 total messages
Started by Darryl 'Well
Fri, 06 Nov 1992 10:21
Excel macro help! !pleh orcam lecxE
Author: 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
Re: Excel macro help! !pleh orcam lecxE
Author: Jonathan Cave
Date: Tue, 10 Nov 1992 16:36
Date: Tue, 10 Nov 1992 16:36
33 lines
1463 bytes
1463 bytes
In article <udarryl.721045294@mcl> udarryl@mcl.ucsb.edu (Darryl 'Well) writes:
|
|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)
There is certainly a better use for A8 -- it is a good place to keep
track of the current version of tex. The problem with the macro as written
is that the variable "tex" does not get updated.
Try the following
|A1 flipit
|A2 =ARGUMENT("tex",2)
|A3 =FOR("count",1,LEN(tex),1)
|A4 =if(count=1,tex,A6)
|A5 =(LEN(A4)+1)-count
|A6 =REPLACE(A4,count,1,MID(A4,(LEN(A4)+1)-count,1))
|A7 =NEXT()
|A8 =RETURN(A6)
Jonathan
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads