I wan't to split a cell with data, into other cells, based on the first data in the original cell. The data from the original cell looks like this (all in the same cell):
Field95-4,Field97-4,Field98-0,Field100-2,Field103-0,Field105-3,Field107-4,Field109-4,Field110-2,Field111-0,Field112-0,Field113-192,Field114-87,Field115-0,Field116-0,Field117-60
It should be split by "," and I found out that I could do that with a script:
Private Sub CommandButton1_Click()
Dim X As Variant
X = Split(Range("A1").Value, ",")
Range("A1").Resize(UBound(X) - LBound(X) + 1).Value = Application.Transpose(X)
End Sub
Then the result is like this:
Field95-4
Field97-4
Field98-0
Field100-2
Field103-0
Field105-3
Field107-4
Field109-4
Field110-2
Field111-0
Field112-0
Field113-192
Field114-87
Field115-0
Field116-0
Field117-60
Now it should look for a cell containing the fieldnumber:
There is a cell containing the text: Field95, and a field with Field97 etc. Then I want to replace the text with the result: Field95 should be replaced by 4, and Field97 should be replaced with 4. etc.
This should be the endresult
I know it's much to ask, but I'we tried a lot, and I can't get it to work.
I'm looking forward to your answers. Thanks in advance!
UPDATE:
This is an excel file I uploaded, so you can see what my question is about. link
UPDATE 2:
Maybe this, combined with an IF statement could be used?
Sub UpdateWhole()
With ActiveSheet.UsedRange
.Replace "A1", "System", xlWhole
.Replace "A2", "System", xlWhole
.Replace "A3", "System", xlWhole
.Replace "B1", "ACC", xlWhole
.Replace "B2", "ACC", xlWhole
End With
End Sub
I don't know if that's an option?
How about:
Sub RedHawk()
Dim X As Variant
X = Split(Range("A1").Value, ",")
Range("A1").Resize(UBound(X) - LBound(X) + 1).Value = Application.Transpose(X)
For i = LBound(X) + 1 To UBound(X) + 1
Cells(i, 1).Value = Split(Cells(i, 1).Value, "-")(1)
Next i
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.