We help IT Professionals succeed at work.

Check out this week's podcast, "Dairy Farms to Databases: Community's Hand in Technology"Listen Now

x

Need an Excel VBA fomula to modify string by adding number to each ASCII character.

Kevin
Kevin asked
on
409 Views
Last Modified: 2014-08-05
I need some VBA code to modify strings based on using a character from a modifying word.  My source strings would be in column A and I would put the formula in each cell to the right of each string, in column B.

What I would like the formula to do is:
1.  Modify every ASCII character in the source string by
2. Using a "modifier" word inside the formula (let's say HELLO for now), change each character in the source word by converting it to a number (using CODE function), adding the CODE number of the letter in the "modifier" word that corresponds to the ROW of the source word.
3. Taking that new number and converting back to a character using CHAR.

For example if the word in Row 1 was "pasta", then I would use the code for "H", since "H" is the number 1 letter in my modifier word.  So...

p would convert to the number 112,
formula would add 72 to that (CODE FOR "H") to get 184
CHAR would convert 184 to ,

then
a would convert to the number 97,
formula would once again add 72 to that (CODE FOR "H") to get 169
CHAR would convert 169 to ©

and so forth, so that the formula that I place in Cell B1 would convert

pasta  (in cell A1) to

¸©»¼©

similarly (in this example) the word in cell A2 would be converted by using the letter "E" which is the second letter (cause it is in row 2)

so if the same word pasta were in row 2, (and I did it right) it would convert to

µ¦¸¹¦

My modifier word will have 13 letters and my list of strings will go up to row 13.

This is not for a practical application, other than a fun project that I am working on.  Fairly urgent and many thanks if someone can put this together :)
Comment
Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Top Expert 2016
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
I would still keep the ModifierIndex as application.caller  restricts the user to enter the formula beyond the row 5 (in this case).

Kris

Author

Commented:
Thanks to both.  I preferred Rgonzo's solution, and also appreciate the fact that krishnkrkc added the ModifierIndex as a restriction (which is something new that I learned).

I am very excited to "code" my list and tempt someone to decode it.  Should be fun.
The code is originally written by me, not Rgonzo.

Kris
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.