'==============================
Attribute VB_Name = "Module1"
Sub NOAAshoreline_read() ' NOAA shoreline -> Enpre Shoreline
Dim lat(1000000) As Double
Dim lon(1000000) As Double
Dim lineid(1000000) As Long
Dim lastrow As Long
Dim lineid_old As Long
Dim lineid_end As Long
Dim i As Long
Dim ii As Long
i = 1
lineid_old = 1
ii = 0
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
lineid_end = Cells(lastrow, 3).Value
Cells(1, 8).Value = lineid_end
Rows(2).Insert '項目とデータの間に空行
[a2].Activate
For i = 1 To lastrow + lineid_end - 1
'Do While Not IsEmpty(ActiveCell)
' i = i + 1
ii = ii + 1 '海岸線ポイントデータのカウント
lat(i) = ActiveCell.Offset(i, 0).Value
lon(i) = ActiveCell.Offset(i, 1).Value
lineid(i) = ActiveCell.Offset(i, 2).Value
If (lineid(i) = lineid_old) Then
ActiveCell.Offset(i, 5).Value = i
ActiveCell.Offset(i, 7).Value = lat(i)
ActiveCell.Offset(i, 8).Value = lon(i)
ActiveCell.Offset(i, 9).Value = lineid(i)
Else
Rows(i + 2).Insert
Cells(i + 1, 8).Activate
Selection.End(xlUp).Select
ActiveCell.Offset(-1, 0).Value = ii - 1
Selection.End(xlDown).Select
[a2].Activate
ii = 0
End If
lineid_old = lineid(i)
Next i
'Loop
End Sub