Link to home
Start Free TrialLog in
Avatar of Luis Diaz
Luis DiazFlag for Colombia

asked on

Excel VBA: keep everything a character & string

Hello experts,

The following attached file contains a reference userform which allows me to add numbers or letters on columns.
User generated imageRef EE comment available at: #a43048196
I would like to take it as a reference to cover the following need:
Dual modulation:
1.Keep everything before specific character.
2.Keep everything after the first comma

Example:
-Input: 58dcRoc / xnk Nc jco
-Character: /
-Expected result 1: 58dcRoc
-Expected result 2: xnk Nc jco

I think that the easiest way to manage this need is through a single character, however I would like to go beyond and I was wondering if there is a way to report specific string instead of a single character.

Example
-Input: 58dcRoc / xnk Nc jco
-String: xn
-Expected result 1: 58dcRoc /
-Expected result 2: k Nc jco


Expected result 2: xnk Nc jco
   

If you have questions, please contact me.
ExtractStringAfterCertainChar.xlsm
Avatar of Bill Prew
Bill Prew

Give this a try.  I added another form, and a SUB in the Module to activate it.

EE29176080.xlsm


»bp
Avatar of Luis Diaz

ASKER

Thank you very much Bill, I tested and it works!

I realized that I need to keep initial information.
Possible to add another option:
-Add a backup option in the form:
Yes/No (Backup active sheet?). Yes: backup initial sheet with the following name YYYYMMDDHHMMSS_Sheet_Name.
Format(Now, "YYYYMMDDMMSS") & ActiveSheet.Name

Open in new window


If the option is complicated to implement always backup sheet with the following name: YYYYMMDDHHMMSS_Sheet_Name.

Thank you again.
Okay, added that to this version.  Keep in mind sheet names can only be 30 characters long, so after adding the date/time to the left I had to truncate the rest to 30 chars.

EE29176080.xlsm


»bp
Great Bill! I will test it and keep you informed.
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great Bill, I will continue the tests tomorrow and let you know.
Bill,
I tested both modes and backup option and it works!
Thank you again!
Welcome Luis, stay safe.

»bp
Thank you Bill, you too.