Const START_ROW = 1
Const END_ROW = 3000

Const COL_TARGET = 1
Const COL_SOURCE = 2

Const TARGET_SHEET = "Sheet1"

Public Sub MERGEROWS()
    Dim s As Worksheet
    
    Set s = ThisWorkbook.Sheets(TARGET_SHEET)
    
    Dim i As Integer
    
    Dim result As String
    
    Dim resultRow As Integer
    resultRow = 1
    result = Trim(s.Cells(1, COL_TARGET).Text)
    For i = START_ROW To END_ROW Step 1
        Dim name As String
        name = Trim(s.Cells(i, COL_SOURCE).Text)
        If name = "" Then
            result = result + Trim(s.Cells(i, COL_TARGET).Value)
            s.Cells(i, COL_TARGET).Value = ""
        Else
            s.Cells(resultRow, COL_TARGET).Value = result
            result = Trim(s.Cells(i, COL_TARGET).Value)
            resultRow = i
        End If
        
    Next
    
End Sub


相关文章:

  • 2021-11-08
  • 2021-12-15
  • 2021-05-17
  • 2022-01-22
  • 2021-08-31
  • 2022-02-28
  • 2022-12-23
猜你喜欢
  • 2021-09-11
  • 2021-12-22
  • 2021-11-07
  • 2021-12-09
  • 2022-01-29
  • 2021-10-23
  • 2021-08-07
相关资源
相似解决方案