日本免费全黄少妇一区二区三区-高清无码一区二区三区四区-欧美中文字幕日韩在线观看-国产福利诱惑在线网站-国产中文字幕一区在线-亚洲欧美精品日韩一区-久久国产精品国产精品国产-国产精久久久久久一区二区三区-欧美亚洲国产精品久久久久

excel拆分單元格的方法 excel如何拆分單元格

No.1
Excel 拆分單元格內(nèi)數(shù)據(jù)是一個高級技能 , 一般情況下 , 很少這么操作 。
當(dāng)然 , 會這個操作的人也很多 。
首先 , 我們理解一下什么是”拆分單元格數(shù)據(jù)” , 本節(jié)講的”拆分單元格”不是把一個列拆分為幾個列 , 而是以某種格式的分隔符為標(biāo)志 , 把單元格內(nèi)的數(shù)據(jù)分別拆開 , 然后添加到不同的單元格中 。

excel拆分單元格的方法 excel如何拆分單元格


這個操作同樣用到一個方法 , 很明顯 , vba 操作數(shù)據(jù)表格的時候 , 首要有個對象 , 然后就是對這個對象進行什么樣的方法處理 。
拆分單元格數(shù)據(jù) , 用到 Range 對象 , 對象的方法是 TextToColumns , 意思就是將文本轉(zhuǎn)換為列 。
方法參數(shù)如下圖所示:

excel拆分單元格的方法 excel如何拆分單元格


No.2
這個方法參數(shù)比較多 , 但是應(yīng)用的時候 , 不會全部寫出來 , 畢竟使用到的僅僅是某些 。
語法:
Range.TextToColumns(Destination、 DataType、 TextQualifier、 ConsecutiveDelimiter、 Tab、Semicolon、Comma、Space、 Other、 OtherChar、 FieldInfo DecimalSeparator、 ThousandsSeparator、 TrailingMinusNumbers)

excel拆分單元格的方法 excel如何拆分單元格


方法它執(zhí)行之后 , 會將拆分的數(shù)據(jù) , 默認(rèn)依次放到被拆分單元格之后 。
如上圖所示 , 粉色部分為被拆分?jǐn)?shù)據(jù) , 拆分之后的數(shù)據(jù)就保存到之后淺灰色單元格內(nèi) 。
這功能在應(yīng)用中 , 常常用到將一些混合的數(shù)據(jù)進行分列處理 。
比如 , 有一列數(shù)據(jù) , 里面有姓名、年齡、身份證號、地址 , 四個關(guān)鍵字內(nèi)容 。
要分別把這四個內(nèi)容放到不同列里面 , 就用這個方法來實現(xiàn) 。
其中 , 這四個關(guān)鍵字之間要有一個分隔符 , 一般有空格 , 逗號 , Tab 制表符 , 分號等字符 。
當(dāng)然 , 如果不喜歡這些字符 , 也可以自定義分隔符 。
使用 Other=True , 和 OtherChar 來定義分隔符 。
注意:
如果 Other 指定為 True , 那么 OtherChar 參數(shù)就為必填項目 , 同時使用 。
參數(shù):Destination 定義了被拆分后的數(shù)據(jù)存放地址 。
No.3
下實例操作演示:

excel拆分單元格的方法 excel如何拆分單元格


Private Sub TextToColumnsChange()Application.DisplayAlerts = FalseDim xValue As StringxValue = https://www.iketao.cn/2023/01/28/a3be0046fea48770/InputBox("數(shù)據(jù)輸入", "請輸入數(shù)據(jù):", "This is a TextToColumn List.")If VBA.Len(VBA.Trim(xValue)) = 0 Then Exit SubDim cell As RangeSet cell = ActiveSheet.Range("B2:B10")With [A1].Offset(2, 0).Resize(cell.Rows.Count, UsedRange.Cells.Columns.Count + 1).Clear '清除原數(shù)據(jù)內(nèi)容 End WithWith cell.Item(1).Offset(0, 1) '清除原拆分內(nèi)容.Select.UnMergeSelection.ClearEnd WithWith cell.Item(1) '添加表頭.Value = "https://www.iketao.cn/2023/01/28/a3be0046fea48770/數(shù)據(jù)內(nèi)容".HorizontalAlignment = xlCenter.Interior.Color = RGB(221, 92, 255).Borders.LineStyle = 1.Columns.AutoFitEnd WithWith cell.Offset(1, 0) '添加原數(shù)據(jù)內(nèi)容.ClearContents.Value = https://www.iketao.cn/2023/01/28/a3be0046fea48770/xValue.HorizontalAlignment = xlCenter.Interior.Color = RGB(221, 92, 255).Borders.LineStyle = 1.Columns.AutoFitWith .Offset(0, 1).Value = .Offset(0, -1).Value.TextToColumns Space:=True'拆分?jǐn)?shù)據(jù)內(nèi)容 并向后填充End WithEnd With'設(shè)置拆分內(nèi)容格式 With cell.Offset(0, 1).Resize(cell.Rows.Count + 1, cell.Cells(2, 1).End(xlToRight).Column - cell.Cells(2, 1).Column) 'Me.Cells(3, Me.Cells.Columns.Count).End(xlToLeft).Column - 2).Columns.AutoFit.RowHeight = 28.HorizontalAlignment = xlCenter.Interior.Color = RGB(221, 223, 255).Borders.LineStyle = 1End With'合并表頭 cell.Cells(1, 2).Resize(1, cell.Cells(2, 1).End(xlToRight).Column - cell.Cells(2, 1).Column).MergeWith cell.Item(1).Offset(0, 1).Value = "https://www.iketao.cn/2023/01/28/a3be0046fea48770/拆分后內(nèi)容"End WithApplication.DisplayAlerts = TrueEnd Sub

推薦閱讀