zoukankan      html  css  js  c++  java
  • vb,wps,excel *

    Sub 分列()
        '以空格为分隔符,连续空格只算1个。对所选中的单元格进行处理
        Dim m As Range, tmpStr As String, s As String
        Dim x As Integer, y As Integer, subStr As String
        If MsgBox("确定要分列处理吗?请确定分列的数据会覆盖它后面的单元格!", _
            vbYesNoCancel + vbQuestion) <> vbYes Then Exit Sub
        For Each m In Selection
            x = m.Column()
            y = m.Row()
            tmpStr = m.Value
            subStr = ""
            For i = 1 To Len(tmpStr)
                s = Mid(tmpStr, i, 1)
                If s = " " And subStr = "" Then  '连续的空格,忽略
                ElseIf s = " " And subStr <> " " Then '空格表示子串结束
                    Cells(y, x).Value = subStr
                    subStr = ""
                    x = x + 1
                ElseIf s <> " " Then  '新子串开始或进行中
                    subStr = subStr & s
                End If
            Next i
            If subStr <> "" Then Cells(y, x).Value = subStr
        Next m
    End Sub
    Sub 分列2()
        '以空格为分隔符,连续空格只算1个。对所选中的单元格进行处理
        Dim m As Range, tmpStr As String, s As String
        Dim x As Integer, y As Integer, subStr As String
        If MsgBox("确定要分列处理吗?请确定分列的数据会覆盖它后面的单元格!", _
            vbYesNoCancel + vbQuestion) <> vbYes Then Exit Sub
        For Each m In Selection
            x = m.Column()
            y = m.Row()
            tmpStr = m.Value
            subStr = ""
            For i = 1 To Len(tmpStr)
                s = Mid(tmpStr, i, 1)
                If s = "," And subStr = "" Then  '连续的空格,忽略
                ElseIf s = "," And subStr <> "," Then '空格表示子串结束
                    Cells(y, x).Value = subStr
                    subStr = ""
                    x = x + 1
                ElseIf s <> "," Then  '新子串开始或进行中
                    subStr = subStr & s
                End If
            Next i
            If subStr <> "" Then Cells(y, x).Value = subStr
        Next m
    End Sub
    博客园:冷色008 百度:冷色008
  • 相关阅读:
    Android studio界面相关设置
    HIVE和HBASE区别
    《梦断代码》经典语录--持续更新
    幽灵漏洞(Ghost gethost)
    服务化实战之 dubbo、dubbox、motan、thrift、grpc等RPC框架比较及选型
    thrift使用总结
    thrift学习总结
    IntelliJ IDEA配置Tomcat(完整版教程)
    sudo执行脚本找不到环境变量和命令
    W-TinyLFU——设计一个现代的缓存
  • 原文地址:https://www.cnblogs.com/--3q/p/9123413.html
Copyright © 2011-2022 走看看