VBE313
Well-known Member
- Joined
- Mar 22, 2019
- Messages
- 686
- Office Version
- 365
- Platform
- Windows
Hello, I have a formula that will extract and sort the unique teams in Column A (Cell D2). For each team, there needs to be a row for 4 operations. "LASER CUT", "PRESS BRAKE", "WELD INSP", "WELD". I created a VBA UDF that will spill two columns into exactly what I need. However, I am wondering if there is a way to do this in Office 365 using native Excel functions. Can I convert this VBA code into a formula based Excel function?
VBA Code:
Function test(uniqueTeams)
Dim i, num, X, z
num = uniqueTeams.Rows.Count
z = 1
X = 0
ReDim A((num * 4) - 1, 1)
For i = 0 To (num * 4) - 2
A(i + X, 0) = uniqueTeams(z).Value
A(i + X, 1) = "LASER CUT"
A((i + X) + 1, 0) = uniqueTeams(z).Value
A((i + X) + 1, 1) = "PRESS BRAKE"
A((i + X) + 2, 0) = uniqueTeams(z).Value
A((i + X) + 2, 1) = "WELD INSP"
A((i + X) + 3, 0) = uniqueTeams(z).Value
A((i + X) + 3, 1) = "WELD"
i = (i + X) + 2
X = 1
z = z + 1
Next i
test = A
End Function