Excel VBA sample
1行目をフィールド名としてセル操作をする例
Public Sub Keisan()
Dim i, j, uid, tuwa, tuwa_total, tuwa_jikans, tuwa_jikan

i = 2: j = 2: tuwa_total = 0
Do
uid = GetField(1, i, "……")
 If uid = "総合計" Then Exit Sub
 If uid = "" Then
  SetField 1, i, "カラム", tuwa_total
  SetField 1, i, "カラム2", Int(tuwa_total * 0.05)
  i = i + 1:
  SetField 1, i, "…………", tuwa_total
  SetField 1, i, "……", Int(tuwa_total * 0.05)
  SetField 1, i, "……", tuwa_total + GetField(1, i, "……")
  SetField 1, i, "……", GetField(1, i, "……")
  SetField 1, i, "……", GetField(1, i, "……") + GetField(1, i, "……")
  
  CopyField 2, j, "……", 1, i
  CopyField 2, j, "……", 1, i
  CopyField 2, j, "……", 1, i
  CopyField 2, j, "……", 1, i
  CopyField 2, j, "……", 1, i
  CopyField 2, j, "……", 1, i
  CopyField 2, j, "……", 1, i
  
  j = j + 1: i = i + 1: tuwa_total = 0
 Else
  If GetField(1, i, "……") = 0 Then
   tuwa_jikans = GetField(1, i, "……")
   tuwa_jikan = Val(Mid(tuwa_jikans, 3, 2)) * 60 + Val(Right(tuwa_jikans, 2))
   tuwa = Application.WorksheetFunction.RoundUp(tuwa_jikan / 180, 0) * 10
   SetField 1, i, "……", tuwa
   tuwa_total = tuwa_total + tuwa
  End If
  i = i + 1
 End If
Loop

End Sub

'Field(シート連番,フィールド)
'フィールド名からカラムを返す

Public Function Field(sheet As Integer, str As String) As Integer
 Dim i, buf: i = 1
 Do
  buf = Worksheets(sheet).Cells(1, i)
  i = i + 1
 Loop Until (buf = str) Or (buf = "")
 If buf = "" Then MsgBox (str + "は無い")
 Field = i - 1
End Function

'SetField(シート番号,行,フィールド名,値)

Public Sub SetField(sheet As Integer, gyo, str As String, v)
 Worksheets(sheet).Cells(gyo, Field(sheet, str)).value = v
End Sub

'GetField(シート連番,行,フィールド名)

Public Function GetField(sheet As Integer, gyo, str As String) As Variant
 GetField = Worksheets(sheet).Cells(gyo, Field(sheet, str)).value
End Function

'CopyField(コピー先 コピー元)

Public Sub CopyField(sheet1 As Integer, gyo1, str1 As String, sheet2 As Integer, gyo2)
 SetField sheet1, gyo1, str1, GetField(sheet2, gyo2, str1)
End Sub

SAMPLE II

Public Sub ConvTest()
Dim i, j, uid, uid2, gd, sid, sid2
i = 1
Do
 i = i + 1
 uid = GetField(1, i, "UID")
 If uid = "" Then Exit Sub
 gd = Left(GetField(1, i, "NONO"), 2)
 If gd = "GF" Then
  sid = "10000C"
 ElseIf gd = "GD" Then
  sid = "10001D"
 ElseIf gd = "GI" Then
  sid = "10002E"
 End If
 j = 1
 Do
  j = j + 1
  uid2 = GetField(2, j, "u_id")
  sid2 = GetField(2, j, "s_id")
 Loop Until ((uid2 = uid) And (sid2 = sid)) Or (uid2 = "")
 If uid2 = "" Then
  MsgBox (uid + "がシート2にない")
 Else
  SetField 1, i, "UID", sid
  SetField 1, i, "NONO", GetField(2, j, "serial_no")
 End If
Loop

End Sub

return