|
▼みか さん:
もう少しコードを整理して、ループによるコード圧縮もできますがとりあえず。
Sub Test()
Dim wX As Variant
Dim wY As Variant
Dim wZ As Variant
Dim dX As Variant
Dim dY As Variant
Dim dZ As Variant
Dim v As Variant
Dim n As Variant
Dim x As Long
ReDim v(1 To 2 * 2 * 2, 1 To 3)
n = Range("X1").Value
If Left(n, 1) = "±" Then
ReDim wX(1 To 2)
wX(1) = Mid(n, 2)
wX(2) = Mid(n, 2) * -1
Else
ReDim wX(1 To 1)
wX(1) = n
End If
n = Range("Y1").Value
If Left(n, 1) = "±" Then
ReDim wY(1 To 2)
wY(1) = Mid(n, 2)
wY(2) = Mid(n, 2) * -1
Else
ReDim wY(1 To 1)
wY(1) = n
End If
n = Range("Z1").Value
If Left(n, 1) = "±" Then
ReDim wZ(1 To 2)
wZ(1) = Mid(n, 2)
wZ(2) = Mid(n, 2) * -1
Else
ReDim wZ(1 To 1)
wZ(1) = n
End If
For Each dX In wX
For Each dY In wY
For Each dZ In wZ
x = x + 1
v(x, 1) = dX
v(x, 2) = dY
v(x, 3) = dZ
Next
Next
Next
Range("X1").Resize(UBound(v, 1), 3).Value = v
End Sub
|
|