I'm relatively inexperienced with VBA. I'm trying to use it to extract size and quantity data from a string. The size is found after the second ":" and before the first ")". Here's an example of one of the text strings, but I'll be doing this for an entire column of data.
Here's what I have so far, but I'm getting a "subscript out of range" error on the italicized row.
This is my first time posting, so let me know if I've left anything out. Thanks!
First Unitarian Church of Dallas T-shirt (Amount: 10.00 USD, Quantity: 2, Size: Adult 2XL) Total: $20.00 |
Here's what I have so far, but I'm getting a "subscript out of range" error on the italicized row.
Rich (BB code):
Sub ExtractSizesAndQuantities()
Dim lastRow As Long
lastRow = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
Dim Size As String
Dim i As Integer
Dim Text As String
For i = 2 To lastRow
Text = Sheets("Orders").Range("D" & i)
Size = Split(Text, ":")(2)
Sheets("Orders").Range("F" & i) = Size
Next i
End Sub
This is my first time posting, so let me know if I've left anything out. Thanks!
Last edited by a moderator: