I am trying to create a macro for an Excel file which has a column (let’s call this column A) of cells, and each cell contains 4 to 5 project Deliverables & Work Products separated by a comma, as well as identified by a tag “DEL” for Deliverable and “WKP” for Work Products.
I wish to accomplish the following with a Macro:
- I would like to keep column A as it is.
- Create a column B for Deliverables, which need to be extracted from cells in Col A
- Likewise, create a column C for Work Products, which need to be extracted from cells in Col A
Let me give an example:
Supposing Cell A1 contains
DEL1: DEL 1 Project Process, DEL2: DEL 2 Project Schedule, WKP1: WKP 1 Work Product Document
Here’s what I want Cell B1 to look like:
DEL1: DEL 1 Project Process, DEL2: DEL 2 Project Schedule
And Cell C1 to look like this:
WKP1: WKP1 Work Product Document
And mind you, not all the cells in Col A will be the exact character length as Cell A1. But they will contain both DELs and WKPs.
Given that the names of the Deliverables and Work Products vary in length, I cannot simply copy Col A and run TextToColumn in order to split it.
So far, the approach I have come up with is to copy Col A to Col B, retain the Deliverables and try to remove Work Products.
As you can see, this entails deleting the part of the string that starts with the comma (“,”) and space (” “) in front of “WKP” and ends with the last character of the Work Product in question (which in this case would be the last character of the entire string itself since it seems that the WKPs are mentioned right after DELs).
While I am able to write a Macro the can find the text “WKP” within each cell range and delete it, I am not able to delete the stuff that comes right after it. In other words, I am only able to produce this for Cell B1:
DEL1: DEL 1 Project Process, DEL2: DEL 2 Project Schedule, 1: 1 Work Product Document
Can someone help me write the Macro to do this? I would appreciate it if the syntax was also explained.
Thanks!
This should do the job. Call it using
=WKP_DEL(A1,"DEL")in B1 and=WKP_DEL(A1,"WKP")in C1.