下午好,
我在分离一列中的数据时遇到一些困难。我有很多行,但上传数据的人将所有内容合并为一列。整个专栏都有教育,年龄,男性,女性和血型。我想采取患者属性并将其分为五列。有没有一种方法可以将数据移动到五列而不使用"文本到列"在"数据"在Excel?
任何帮助都将不胜感激。
谢谢。
change = function() {
var matches = ["every", "most", "that", "half", "much", "the", "another", "her", "my", "their", "a", "an", "his", "neither", "these", "all",
"its", "no", "this", "any", "those", "both", "least", "our",
"what", "each", "less", "several", "which", "either", "many", "some",
"whose", "enough", "more", "such", "your"
];
// get the current value of the "myTextField" element
var myTextFieldValue = document.getElementById('myTextField').value;
// split this string at every space character - we now have
// an array of individual words
var myTextFieldWords = myTextFieldValue.split(' ');
// for each of these words, test if the "matches" array contains
// the word. If it does, surround it with a <span class="match"> tag.
var formattedWords = myTextFieldWords.map(function(word) {
if (matches.indexOf(word) !== -1) {
return '<span class="match">' + word + '</span>';
} else {
return word;
}
});
// formattedWords now looks like this:
// ['<span>his</span>', 'first' 'entering', 'a' .... ]
// join all the items in the formattedWords array (with a
// space between each word) into a single string, and set
// it as the innerHTML of the #title element
document.getElementById('title').innerHTML = formattedWords.join(' ');
}
答案 0 :(得分:3)
使用 A1 中的数据,在 B1 中输入:
=LEFT(TRIM(MID(SUBSTITUTE($A1," ",REPT(" ",999)),COLUMNS($A:A)*999-998,999)),LEN(TRIM(MID(SUBSTITUTE($A1," ",REPT(" ",999)),COLUMNS($A:A)*999-998,999)))-2)
C1 中的输入:
=RIGHT(TRIM(MID(SUBSTITUTE($A1," ",REPT(" ",999)),COLUMNS($A:A)*999-998,999)),2)
在 D1 中输入:
=TRIM(MID(SUBSTITUTE($A1," ",REPT(" ",999)),COLUMNS($A:B)*999-998,999))
并在 E1 中输入:
=TRIM(MID(SUBSTITUTE($A1," ",REPT(" ",999)),COLUMNS($A:C)*999-998,999))
如果年龄 2 数字(大于9且小于100),这将有效
另请注意,我已将男/女字段保留为单个 2 数字字段。
答案 1 :(得分:2)
对于vba,这取决于年龄总是两位数。
Sub splitStr()
Dim rng As Range
Dim ws As Worksheet
Dim spltStr() As String
Set ws = Sheets("Sheet4")
With ws
For Each rng In .Range(.Cells(2, 1), .Cells(.Rows.Count, 1).End(xlUp))
spltStr = split(Trim(rng))
rng.Offset(, 1) = Left(spltStr(0), Len(spltStr(0)) - 2)
rng.Offset(, 2) = --Right(spltStr(0), 2)
rng.Offset(, 3) = --Left(spltStr(1), 1)
rng.Offset(, 4) = --Right(spltStr(1), 1)
rng.Offset(, 5) = spltStr(2)
Next rng
End With
End Sub
这不会做标题。那些是手工打字的。