![]() |
How do I capture the last character in a string inside a macro?
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 |
How do I capture the last character in a string inside a macro?
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 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 |
All times are GMT +1. The time now is 12:33 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com