spartan .R
asked on
VBA to find and replace and sort the valueswithin each cell
i have a data to find and replace a values with other values in a column,ex "arjun + suresh + rajesh +marco" which has unique field to be replaced
ie: arjun should be replaced with 03 arjun, suresh should be replaced with 02 suresh, and rajesh with 08 rajesh, and marco with 06 marco.
after replacement the output will be "03 arjun +02 suresh +08 rajesh + 06 marco"
once we replace the values for the entire column in the same way mentioned above the each cell values should be sorted like ascending order with number "02 suresh+03 arjun +06 marco +08 rajesh"
ie: arjun should be replaced with 03 arjun, suresh should be replaced with 02 suresh, and rajesh with 08 rajesh, and marco with 06 marco.
after replacement the output will be "03 arjun +02 suresh +08 rajesh + 06 marco"
once we replace the values for the entire column in the same way mentioned above the each cell values should be sorted like ascending order with number "02 suresh+03 arjun +06 marco +08 rajesh"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot for the code could you please explain each and every line of the code and send me it would be very useful for me to workaround with it.
ASKER
Also this is just for one column i have three similar column.I see in the code you have used listobjestcs(1) in the code to refer the table .If i want to use three other columns how do i refer it after creating a table for it.Thanks in advance
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Am very sorry for that because i don't want to share the file because its sensitive.Attached the file with three columns which has to be replaced and sorted .Ignore if there are no values for replacement.
Relacement.xlsx
Relacement.xlsx
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes that + will always separate different terms.yeah as of now there are no spaces i have checked several workbooks,in caes lets say tmrw for a two or three cells has spaces . please consider tat part as well . thanks in advance.i have checked your code and it works like champ.you are superb dude.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks alot buddy Sorry for an late reply.the code works like an champ.Still i have two more questions.this very small you can explain me in words if its not complicated.1.Now the replacement columns are in 1 ,2,3 lets say if its in 5,6,7 how do i change it accordingly.one i should change in master columns(5),columns(6),colu mns(7). but in replacement sub procedure am not sure where to change.2.i want to highlight if the value doesnt get replaced with values.So that it will be easier for me to QC. thank you
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks alot
ASKER
Hi Need an additional help on the same.once the cells value sorted by numbers I want to remove the numbers .Could you please add an additional code for the same please.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Thanks,
After doing quality checks with the automation i found one bug and it was sent from my manager if you can notice row a566:a571 its FIXED ICS\LABA after replacement it should be 05 FIXED ICS\LABA ,but its getting replaced as 04 FIXED LAMA\LABA.Can you fix it i just noticed only this bug,there are chances to be many .also can we go to previous methodology like creating three tables with columns"find this" and "replace ".
After doing quality checks with the automation i found one bug and it was sent from my manager if you can notice row a566:a571 its FIXED ICS\LABA after replacement it should be 05 FIXED ICS\LABA ,but its getting replaced as 04 FIXED LAMA\LABA.Can you fix it i just noticed only this bug,there are chances to be many .also can we go to previous methodology like creating three tables with columns"find this" and "replace ".
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
In the above attached file when i comment delete codes and run the macro the replacement and sorting doesn't happen for all the rows.Can i know why please.replacement and sorting has happened only for rows 572 :579.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi ,
You have created a procedure Sub DeleteCodes(rg As Range) which After sorting, the two-digit numbers will be removed.is it possible to remove blank spaces after each string
You have created a procedure Sub DeleteCodes(rg As Range) which After sorting, the two-digit numbers will be removed.is it possible to remove blank spaces after each string
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
1. Created a two column Table in worksheet Replacements with the original text and its desired replacement
2. Added a button and instructions for how to use the macro to worksheet Data
3. Corrected some apparent typos in worksheet Data column A to make the test cases consistent with the desired results
4. Revised the macro to point to the two column Table
5. Revised the macro to separate each API with " + nn " where nn is the number from column B on worksheet Replacements
6. Stored the code in a regular Module, and saved the file with .xlsm file extension
Note that you must enable macros when you open the workbook.
Open in new window
WheezerQ29165985.xlsm