PC Review


Reply
Thread Tools Rate Thread

How do I capture the last character in a string inside a macro?

 
 
JasonK
Guest
Posts: n/a
 
      25th Mar 2010

Thanks in advance.

I've written a macro that will take data from my worksheet and compile
a report that I have to write often at work. The customer's name is
mentioned in the report several times, once in the possessive. I can
make the macro place a " 's " at the proper time, but I can't make it
not place it there when the customer's name ends in " s ". I need to
call the last character in the name string, called "LastName" and
determine if it's an " s " or not. Can someone please teach me how to
do that?

Also, I will end up sharing this spreadsheet with co-workers and I
don't want them to have access to the code. Not because I don't want
to share; I don't want them to wreck it. The spreadsheet will sit in a
directory on our computers that is common to all workers. I could just
save a copy and over write occasionally, but if there is a way to lock
the code, it would be easier for me.

Thanks guys and girls. I appreciate all the help. The thread on the
"Randomize Timer" was phenomenal. It helped me a great deal. When I
ran my dice program using Randomize Timer at the beginning of the
macro, and just using "RND" to "roll the dice", it lost the correct
amount of money within normal parameters.

JasonK


 
Reply With Quote
 
 
 
 
Paul Robinson
Guest
Posts: n/a
 
      25th Mar 2010
Hi
Text string issue
If Right(teststring,1)<>"s" then
teststring = teststring & "'s"
end if

will put 's on the end if teststring does not end in s.
To protect code in the VBEditor do Tools, VBAProjectProperties,
Protection and set a password.

regards
Paul

On Mar 25, 3:29*am, JasonK <moti...@yahoo.com> wrote:
> Thanks in advance.
>
> I've written a macro that will take data from my worksheet and compile
> a report that I have to write often at work. The customer's name is
> mentioned in the report several times, once in the possessive. I can
> make the macro place a " 's " at the proper time, but I can't make it
> not place it there when the customer's name ends in " s ". I need to
> call the last character in the name string, called "LastName" and
> determine if it's an " s " or not. Can someone please teach me how to
> do that?
>
> Also, I will end up sharing this spreadsheet with co-workers and I
> don't want them to have access to the code. Not because I don't want
> to share; I don't want them to wreck it. The spreadsheet will sit in a
> directory on our computers that is common to all workers. I could just
> save a copy and over write occasionally, but if there is a way to lock
> the code, it would be easier for me.
>
> Thanks guys and girls. I appreciate all the help. The thread on the
> "Randomize Timer" was phenomenal. It helped me a great deal. When I
> ran my dice program using Randomize Timer at the beginning of the
> macro, and just using "RND" to "roll the dice", it lost the correct
> amount of money within normal parameters.
>
> JasonK


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: special character inside a string Chris Microsoft VB .NET 0 13th Apr 2005 02:48 PM
Re: special character inside a string Herfried K. Wagner [MVP] Microsoft VB .NET 0 13th Apr 2005 09:39 AM
Re: special character inside a string Mattias Sjögren Microsoft VB .NET 0 13th Apr 2005 09:37 AM
Re: special character inside a string Cor Ligthert Microsoft VB .NET 0 13th Apr 2005 09:36 AM
Re: special character inside a string Darren Barrick Microsoft VB .NET 0 13th Apr 2005 09:06 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:19 AM.