zoukankan      html  css  js  c++  java
  • 一个用来将Excel中同一个人的多行记录中的特定列合并到第一行的宏

    宏本身很简单,不过处理带链接的单元格,费了不少劲,主要是原来有个陋习,取单元格的值时,比较懒,没用cells(i,j).value,而是直接用cells(i,j),所以给添加链接时,因为最后一个参数使用了Cells(i,j),而不是Cells(i,j).value,导致类型不匹配报错.

    Sub MergeRow()
    Dim i, j, k As Integer
        Dim iStart As Integer
        iStart = 2
        For i = 3 To 65536
            If Cells(i, 3).Value = "" Then Exit For
            If Cells(i, 3).Value <> Cells(iStart, 3).Value Then
                iStart = i
            Else
                Cells(iStart, 55).Value = Cells(iStart, 55).Value + ";" + Cells(i, 55).Value
                Cells(iStart, 54).Value = Cells(iStart, 54).Value + ";" + Cells(i, 54).Value
                Cells(iStart, 50).Value = Cells(iStart, 50).Value + ";" + Cells(i, 50).Value
                For k = 57 To 100
                    If Cells(i, k) <> "" Then
                        For j = 57 To 100
                            If Cells(iStart, j) = "" Then
                                Cells(iStart, j).Hyperlinks.Add Cells(iStart, j), Cells(i, k).Hyperlinks(1).Address, "", "", Cells(i, k).Value
                                Exit For
                            End If
                        Next j
                    Else
                        Exit For
                    End If
                Next k
            End If
        Next i
        MsgBox "处理完毕"
    End Sub

  • 相关阅读:
    hibernate关联关系(多对多)
    hibernate关联关系(一对多)
    hibernate主键生成策略
    hibernate01
    利用Struts2拦截器完成文件上传功能
    layui的CRUD案列
    Struts2的CRUD
    Git中.gitignore文件不起作用
    在 Visual Studio 中使用 Q# 进行量子编程
    Elasticsearch 搜索
  • 原文地址:https://www.cnblogs.com/techrich/p/1898900.html
Copyright © 2011-2022 走看看