Forum Discussion
jklemm1
Oct 17, 2022Copper Contributor
Extraction formula help
I need a formula to extract the AC-UG from the text string below and then put them in two separate columns without using the text-to-columns feature - TIA! EM-AC-UG-Course-ENG-122-Week3-TOT
OliverScheurich
Oct 17, 2022Gold Contributor
jklemm1
Oct 17, 2022Copper Contributor
I opened your attachment, and this is what I need returned...But I do not see the formula and how you produced this. Also, could you explain a little more about the Power Query option?
- OliverScheurichOct 17, 2022Gold Contributor
Sub extract() Dim i As Long Dim j As Long Dim first As Long Dim second As Long Dim third As Long j = Range("B" & Rows.Count).End(xlUp).Row For i = 2 To j first = Application.WorksheetFunction.Find("-", Cells(i, 2)) second = Application.WorksheetFunction.Find("-", Cells(i, 2), first + 1) third = Application.WorksheetFunction.Find("-", Cells(i, 2), second + 1) Cells(i, 3).Value = Mid(Cells(i, 2), first + 1, second - first - 1) Cells(i, 4).Value = Mid(Cells(i, 2), second + 1, third - second - 1) Next i End Sub
Another alternative could be VBA code. In the attached file you can click the button in cell F2 to run the macro.
- OliverScheurichOct 17, 2022Gold Contributor
I've copied your data and pasted it in the blue table. Then i clicked in any cell of the green table, right-clicked with the mouse and selected refresh.
There are several free tutorials on the internet if you want to start with Power Query. I personally learned a lot about Power Query by the solutions provided by the experts of the Microsoft Tech Community.
In the attached file you can view the Power Query Editor, the applied steps and formulas:
In the Power Query Editor you can follow the steps of data manipulation:
You can as well view the formulas that created the query: