(標準モジュール)
-----------------------------------------------------------
Sub Test1()
Dim GroupValue(1 To 4, 1 To 4) As Variant
GroupValue(1, 2) = -1198047
GroupValue(1, 3) = -776214
GroupValue(1, 4) = 1508616
GroupValue(2, 1) = 1200780
GroupValue(2, 3) = -383483
GroupValue(2, 4) = 21704
GroupValue(3, 1) = 776214
GroupValue(3, 2) = 383483
GroupValue(3, 4) = -91303
GroupValue(4, 1) = -1506205
GroupValue(4, 2) = -21704
GroupValue(4, 3) = 91303
Dim NewSheet As Worksheet
Dim DestinationRow As Long
Set NewSheet = Workbooks.Add.Worksheets(1)
DestinationRow = 1
With NewSheet
.Cells(DestinationRow, 1).Value = "売上営業所ID"
.Cells(DestinationRow, 2).Value = "仕入営業所ID"
.Cells(DestinationRow, 3).Value = "売上金額"
.Cells(DestinationRow, 4).Value = "仕入金額"
.Cells(DestinationRow, 5).Value = "差額"
End With
Dim x As Long
Dim y As Long
Dim SalesAmount As Variant
Dim PurchaseAmount As Variant
For x = LBound(GroupValue, 1) To UBound(GroupValue, 1)
For y = LBound(GroupValue, 2) To UBound(GroupValue, 2)
SalesAmount = Empty
PurchaseAmount = Empty
If IsEmpty(GroupValue(x, y)) = False And IsNumeric(GroupValue(x, y)) = True Then
SalesAmount = CDec(GroupValue(x, y))
End If
If IsEmpty(GroupValue(y, x)) = False And IsNumeric(GroupValue(y, x)) = True Then
PurchaseAmount = CDec(GroupValue(y, x))
End If
If IsEmpty(SalesAmount) = False And IsEmpty(PurchaseAmount) = False Then
DestinationRow = DestinationRow + 1
With NewSheet
.Cells(DestinationRow, 1).Value = x
.Cells(DestinationRow, 2).Value = y
.Cells(DestinationRow, 3).Value = SalesAmount
.Cells(DestinationRow, 4).Value = PurchaseAmount
.Cells(DestinationRow, 5).Value = SalesAmount + PurchaseAmount
End With
GroupValue(x, y) = Empty
GroupValue(y, x) = Empty
End If
Next
Next
Set NewSheet = Nothing
End Sub
-----------------------------------------------------------
以上のようなマクロを実行したい、ということでしょうか。