1. 程式人生 > >記錄一次用VB合併資料,確實很好用

記錄一次用VB合併資料,確實很好用

開發十年,就只剩下這套架構體系了! >>>   

Sub 合併()
Dim row, col, val As Double

For row = 1 To 710 Step 1
    For col = 1 To 15 Step 1
        If IsNumeric(sheet2.Cells(row, col)) And IsNumeric(Sheet3.Cells(row, col)) Then
            val = sheet2.Cells(row, col).value + Sheet3.Cells(row, col).value
             If val > 0.001 And IsEmpty(sheet1.Cells(row, col)) Then
                sheet1.Cells(row, col).value = val
                sheet1.Cells(row, col).Interior.ColorIndex = 3
            End If
        End If
    Next col
Next row

MsgBox "資料合併完成!"
        
End Sub