I'm given the following sample data:
| Item | Demand Qty | Comments |
|---|---|---|
| 69-55179-78 MOD A | 4 | SHORT NAS1291C02M RCVD 09/14 COMMIT: 2 W/S 09/29 + 2 W/S 09/30 |
Which tells me that, of the required 4 units, 2 will ship 9/29 and 2 more will ship 9/30.
I'm attempting to split the row by unit to give a ship date for each piece. I've run the following code to split the line by quantity:
Sub ExpandRows()
Dim dat As Variant
Dim i As Long
Dim rw As Range
Dim rng As Range
Set rng = ActiveSheet.UsedRange
dat = rng
On Error Resume Next
For i = UBound(dat, 1) To 2 Step -1
If dat(i, 3) > 1 Then
Set rw = rng.Rows(i).EntireRow
rw.Offset(1, 0).Resize(dat(i, 3) - 1).Insert
rw.Copy rw.Offset(1, 0).Resize(dat(i, 3) - 1)
rw.Cells(1, 3).Resize(dat(i, 3), 1) = 1
End If
Next
End Sub
So now I have this:
| Item | Demand Qty | Comments |
|---|---|---|
| 69-55179-78 MOD A | 1 | SHORT NAS1291C02M RCVD 09/14 COMMIT: 2 W/S 09/29 + 2 W/S 09/30 |
| 69-55179-78 MOD A | 1 | SHORT NAS1291C02M RCVD 09/14 COMMIT: 2 W/S 09/29 + 2 W/S 09/30 |
| 69-55179-78 MOD A | 1 | SHORT NAS1291C02M RCVD 09/14 COMMIT: 2 W/S 09/29 + 2 W/S 09/30 |
| 69-55179-78 MOD A | 1 | SHORT NAS1291C02M RCVD 09/14 COMMIT: 2 W/S 09/29 + 2 W/S 09/30 |
I need to distribute the dates from the comments column so that I'm left with this:
| Item | Demand Qty | Comments |
|---|---|---|
| 69-55179-78 MOD A | 1 | W/S 09/29 |
| 69-55179-78 MOD A | 1 | W/S 09/29 |
| 69-55179-78 MOD A | 1 | W/S 09/30 |
| 69-55179-78 MOD A | 1 | W/S 09/30 |
I've scoured forums and how-to's and haven't been able to find anything that fits this situation. The comments are different every time so I need to find the instances of "W/S" but I need the quantity before it and the date after and then insert a single date per row based on that quantity. I'm kind of at a loss as I've been staring at this for 2 days now. I know that the Stack isn't here to do it for me so I would consider an acceptable answer to be something that points me down a productive track.
EDIT Here is a larger subset of the data I'm working with:
| Item | Demand Qty | Comments |
|---|---|---|
| 115E5665G1 | 1 | |
| 115E5684G1 | 1 | |
| 115E6575G1 MOD A | 3 | 1 W/S 09/21+ 1 W/S 09/22+ 1 W/S 09/23 |
| 115E6582G1 MOD A | 2 | 1 W/S 09/15 |
| 115E6582G1 MOD A | 2 | 1 W/S 09/19 + 1 W/S 09/20 |
| 115E6582G1 MOD A | 2 | SHORT:115E6716G12 : 14-SEP-22 QTY 77 ETA 9/17 COMMIT: 1 W/S 09/21 + 1 W/S 09/22 |
| 115E6582G1 MOD A | 2 | SHORT:115E6716G12 : 14-SEP-22 QTY 77 ETA 9/17 COMMIT: 1 W/S 09/23 + 1 W/S 09/26 |
| 115E6582G1 MOD A | 2 | SHORT:115E6716G12 : 14-SEP-22 QTY 77 ETA 9/17 COMMIT: 1 W/S 09/27 + 1 W/S 09/28 |
| 115E6582G1 MOD A | 2 | SHORT:115E6716G12 : 14-SEP-22 QTY 77 ETA 9/17 COMMIT: 2 W/S 09/29 |
| 115E6582G1 MOD A | 1 | SHORT:115E6716G12 : 14-SEP-22 QTY 77 ETA 9/17 COMMIT: 1 W/S 09/30 |
| 115E6582G1 MOD A | 2 | SHORT:115E6716G12 : 14-SEP-22 QTY 77 ETA 9/17 COMMIT: 2 W/S 10/03 |
| 115E6582G1 MOD A | 2 | SHORT:115E6716G12 : 14-SEP-22 QTY 77 ETA 9/17 COMMIT: 2 W/S 10/04 |
The comments come from an international sister facility so the formatting can be problematic. I appreciate all the responses so far. Just looking for that one that pushes me towards a working solution.




