|
▼mori さん:
横から失礼
このようでどうでしょう。
逆回しで
' lngPresentRowIndex = 4
' For lngRow = 31 To lngMaxRow
lngPresentRowIndex = 4 + (lngMaxRow - 31) ' 此処
For lngRow = lngMaxRow To 31 Step -1 ' 此処
strGyoNO = Worksheets("TMP1").Cells(lngRow, 1).Value
strTekiyo = Worksheets("TMP1").Cells(lngRow, 2).Value
strSuryo = Worksheets("TMP1").Cells(lngRow, 3).Value
strTani = Worksheets("TMP1").Cells(lngRow, 4).Value
strTanka = Worksheets("TMP1").Cells(lngRow, 5).Value
strKingaku = Worksheets("TMP1").Cells(lngRow, 6).Value
strSyokei = Worksheets("TMP1").Cells(lngRow, 6).Value
If Left(strGyoNO, 1) = "-" Then
lngLength = Len(strGyoNO)
strKakkoGyoNO = Mid(strGyoNO, 2, lngLength - 1)
strKakkoGyoNO = "'(" & strKakkoGyoNO & ")"
.Cells(lngPresentRowIndex, 1).Value = strKakkoGyoNO
Else
.Cells(lngPresentRowIndex, 1).Value = strGyoNO
End If
'文字列チェック
strTrimedTekiyo = strTekiyo
strTrimedTekiyo = StrConv(strTrimedTekiyo, 4)
strTrimedTekiyo = Replace(strTrimedTekiyo, " ", "")
lngTekiyoLength = InStr(strTrimedTekiyo, "値引")
If lngTekiyoLength > 0 Then
strTrimedTekiyo = Mid(strTrimedTekiyo, lngTekiyoLength, 2)
End If
If strTrimedTekiyo = "合計" Then
.Cells(lngPresentRowIndex, 2).Value = strTekiyo
.Cells(lngPresentRowIndex, 6).Value = strKingaku
' .Rows(lngPresentRowIndex).Insert ' 合計の上
.Rows(lngPresentRowIndex + 1).Insert ' 合計の下 ' 此処
ElseIf strTrimedTekiyo = "値引" Then
.Cells(lngPresentRowIndex, 2).Value = strTekiyo
.Cells(lngPresentRowIndex, 6).Value = strKingaku
.Rows(lngPresentRowIndex).Insert ' 値引の上 ' 此処
Else
.Cells(lngPresentRowIndex, 2).Value = strTekiyo
.Cells(lngPresentRowIndex, 3).Value = strSuryo
.Cells(lngPresentRowIndex, 4).Value = strTani
End If
lngPresentRowIndex = lngPresentRowIndex - 1 'インデックスを減算 ' 此処
Next
|
|