In case some people are interested in the answers to the discussion with @Ondrej, here are two codes, the first is static and the second is dynamic:Sub test()Dim ws As WorksheetSet ws = Sheets("Sheet1")Dim actualRange As RangeFor Each actualRange In ws.Range(ws.Cells(ws.Rows.Count, 1).End(xlUp), ws.Cells(ws.Rows.Count, 1).End(xlUp).End(xlToRight))If InStr(Trim(actualRange), ":") > 0 ThenactualRange.Offset(1, 0).Value = Split(actualRange.Value, ":")(1)actualRange.Offset(0, 0).Value = Split(actualRange.Value, ":")(0)End IfNextEnd Sub&Sub test()Dim ws As WorksheetSet ws = Sheets("Sheet1")Dim actualRange As RangeDim tmpString As StringFor Each actualRange In ws.Range(ws.Cells(ws.Rows.Count, 1).End(xlUp), ws.Cells(ws.Rows.Count, 1).End(xlUp).End(xlToRight))tmpString = actualRange.ValueIf InStr(Trim(tmpString), ":") > 0 ThenactualRange.Offset(0, 0).Value = Split(tmpString, ":")(0)actualRange.Offset(1, 0).Value = Split(tmpString, ":")(1)End IfNextEnd Sub 这篇关于VBA-拆分单元格值并将其放入下面的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-18 19:04