Sub TEST3()

Dim str(30) As String

 button_row = ActiveSheet.Shapes(Application.Caller).TopLeftCell.Row

'--------------------------------------
 beforeid_column=5
 zone_src_column=6
 zone_dst_column=7
 addr_src_column=9
 addr_dst_column=11
 service_column=12

 output_変更config_column
 output_切り戻しconfig_column

'-------------------------------------
 
 str(0) = "set policy id " & Cells(button_row,5).Value & " from " & Cells(button_row, 6).Value & " to " & Cells(button_row, 7).Value & " " & Cells(button_row, 9).Value
 str(1) = "set policy id xx"

 j = 2
 
 isrc = button_row
 While Cells(isrc, 9).Value <> ""
  isrc = isrc + 1
  If Cells(isrc, 9).Value <> "" Then
    str(j) = "set src-addr " & " " & Cells(isrc, 9).Value
    j = j + 1
  End If
 Wend
 
 
 idst = button_row
 While Cells(idst, 11).Value <> ""
  idst = idst + 1
  If Cells(idst, 11).Value <> "" Then
    str(j) = "set dst-addr " & " " & Cells(idst, 11).Value
    j = j + 1
  End If
  Wend

   
 iserv = button_row
 While Cells(iserv, 13).Value <> ""
  iserv = iserv + 1
  If Cells(iserv, 13).Value <> "" Then
    str(j) = "set service " & " " & Cells(iserv, 13).Value
    j = j + 1
  End If
 Wend

 For k = 0 To j
   Cells(button_row + k, 20).Value = str(k)
 Next k

End Sub