Thread: Re-word text
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Re-word text

Looking at your Mid function call in isolation...

Mid(c.Value, 2, Len(c.Value))

Theoretically, your 3rd argument should be Len(c.Value)-1; however,
Len(c.Value) works because any value greater than the number of characters
remaining in the text will return only the remaining characters. So, this
would have worked just as well...

Mid(c.Value, 2, 100000)

However, the reason I'm posting this message is to point out for those
reading this thread that the 3rd argument is optional and, when omitted, it
automatically returns the remainder of the characters in the text. So, your
Mid function call could have been this as well...

Mid(c.Value, 2)

meaning this active code statement would have also worked inside your
loop...

c.Value = Trim(Mid(c.Value, 2)) & ".x"

--
Rick (MVP - Excel)


"Mike H" wrote in message
...
Hi,

Alt+F11 to open VB editor. right click the 'Modules' in Personal.xls and
insert module. Double click the newly insertede module and paste the code
in
that.

Select the data and run it.

Sub servient()
For Each c In Selection
c.Value = Trim(Mid(c.Value, 2, Len(c.Value))) & ".x"
Next
End Sub

On closing Excel be sure to save Personal.xls when prompted

Mike

"Tenacity9" wrote:

My cells have content like this:

.VAVXB
.CQQAP
.WQQLK

I would like to, in an automated way, change them (either individually or
by
highlighting the range) to:

VAVXB.X
CQQAP.X
WQQLK.X

In other words, delete the leading . and add .X at the end.

I'm not too good at macros, but I tried recording the keystrokes in one
of
the cells, but re-playing the macro in another cell did not work.

Appreciate your assistance. If a macro, the full text which I can cut
and
paste verbatim will be ideal.

Also, if a macro, I'm not sure how to enter and save it under All
Personal
Workbooks, so it is available to all my workbooks. How is this done?
Thanks.