I have found the following code, I need to make some changes to it, and I cannot identify, where to make the changes.
Currently In “Column C” I have cells that have text, that I need to split out, based on the word “at”.
The Code shown below does split the text out as needed, however it is being Split, with the left portion of the string, going into “Column E”, and the Right portion of the string, going into “Column F”, of the same row.
The desired results is to have the Left portion of the string to be in “Column C”, OFFSET 1 row down,
And the Right Portion of the string to be in “Column C”, OFFSET 2 rows down.
If some would be kind enough to show me where the changes, need to be made, and what method, would best be used to do this, I would appreciate it.
Thank you in advance.
Sub ptest()
Dim b!, y, p, i!, k(), e
With Range("C1", Range("C" & Rows.Count).End(xlUp)).Resize(, 1)
p = .Value
End With
ReDim k(1 To UBound(p, 1), 1 To 2)
For i = 1 To UBound(p, 1)
b = 1
For Each e In Split(p(i, 1), " at ")
k(i, b) = e
b = 1 + b
Next
Next
Range("e1").Resize(i, 2).Value = k
End Sub
<html><head><title>Excel Jeanie HTML</title></head><body>
<!-- ######### Start Created Html Code To Copy ########## -->
<!-- ######### End Created Html Code To Copy ########## -->
</body></html>
Currently In “Column C” I have cells that have text, that I need to split out, based on the word “at”.
The Code shown below does split the text out as needed, however it is being Split, with the left portion of the string, going into “Column E”, and the Right portion of the string, going into “Column F”, of the same row.
The desired results is to have the Left portion of the string to be in “Column C”, OFFSET 1 row down,
And the Right Portion of the string to be in “Column C”, OFFSET 2 rows down.
If some would be kind enough to show me where the changes, need to be made, and what method, would best be used to do this, I would appreciate it.
Thank you in advance.
Sub ptest()
Dim b!, y, p, i!, k(), e
With Range("C1", Range("C" & Rows.Count).End(xlUp)).Resize(, 1)
p = .Value
End With
ReDim k(1 To UBound(p, 1), 1 To 2)
For i = 1 To UBound(p, 1)
b = 1
For Each e In Split(p(i, 1), " at ")
k(i, b) = e
b = 1 + b
Next
Next
Range("e1").Resize(i, 2).Value = k
End Sub
<html><head><title>Excel Jeanie HTML</title></head><body>
<!-- ######### Start Created Html Code To Copy ########## -->
Excel Workbook | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
1 | * | * | * | * | * | * | * | ||
2 | * | * | Madison at Polk | * | Madison | Polk | * | ||
3 | * | * | * | * | * | * | * | ||
4 | * | * | Van Ness at Fell | * | Van Ness | Fell | * | ||
5 | * | * | * | * | * | * | * | ||
6 | * | * | * | * | * | * | * | ||
7 | * | * | Desired Results | * | * | * | * | ||
8 | * | * | Madison at Polk | * | * | * | * | ||
9 | * | * | Madison | * | * | * | * | ||
10 | * | * | Polk | * | * | * | * | ||
11 | * | * | * | * | * | * | * | ||
12 | * | * | * | * | * | * | * | ||
13 | * | * | Van Ness at Fell | * | * | * | * | ||
14 | * | * | Van Ness | * | * | * | * | ||
15 | * | * | Fell | * | * | * | * | ||
16 | * | * | * | * | * | * | * | ||
Sheet1 |
<!-- ######### End Created Html Code To Copy ########## -->
</body></html>
Last edited: