Sub filName()
Dim MyF As String
'前回のデータをクリアー
Range("A8:V65536").Select
Selection.Clear
'ファイル名の取得
Dim myRow As Long
myRow = 8
MyF = Dir(ThisWorkbook.Path & "\*")
If MyF <> "" Then
Do Until MyF = ""
Cells(myRow, "D").Select 'ハイパーリンク
Cells(myRow, "B").Value = myRow - 7
Cells(myRow, "E").Value = MyF 'ファイル名
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=Cells(myRow, "E").Value, TextToDisplay:="■"
MyF = Dir()
myRow = myRow + 1
Loop
End If
'並べ替え
Range("D8:E65536").Select
Selection.Sort Key1:=Range("E8"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
:=xlStroke
'罫線
Range("B8:E2000").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = xlAutomatic
End With
Range("E8").Select
End Sub
|