Sub wsdelete()
Dim wd As Worksheet
Application.DisplayAlerts = False
For Each wd In Worksheets
If Left(wd.Name, 4) <> "main" Then
wd.delete
End If
Next
Application.DisplayAlerts = True
End Sub
Sub number()
Dim n As Long
For n = 2 To Range("B65536").End(xlUp).Row
Range("A" & n).Value = n - 1
Next
End Sub
Sub narabe1()
ActiveWorkbook.Worksheets("main").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("main").Sort.SortFields.Add Key:=Range("B2:B317"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("main").Sort
.SetRange Range("A1:G317")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Sub narabe2()
ActiveWorkbook.Worksheets("main").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("main").Sort.SortFields.Add Key:=Range("A2:A317"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("main").Sort
.SetRange Range("A1:G317")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Sub denpyo()
Dim wFm As Worksheet
Dim wTo As Worksheet
Dim moto As Long
Dim saki As Long
Dim mx As Long
Set wFm = Worksheets("main")
wsdelete
wFm.Activate
number
narabe1
For moto = 2 To wFm.Range("B65536").End(xlUp).Row
If wFm.Range("B" & moto).Value <> wFm.Range("B" & moto - 1).Value Then
If moto > 2 Then
mx = Range("K65536").End(xlUp).Row
Range("B16:K" & mx).Borders(xlDiagonalDown).LineStyle = xlNone
Range("B16:K" & mx).Borders(xlDiagonalUp).LineStyle = xlNone
With Range("B16:K" & mx)
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlEdgeBottom).Weight = xlThin
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeRight).Weight = xlThin
.Borders(xlInsideVertical).LineStyle = xlContinuous
.Borders(xlInsideVertical).Weight = xlHairline
.Borders(xlInsideHorizontal).LineStyle = xlContinuous
.Borders(xlInsideHorizontal).Weight = xlHairline
End With
End If
saki = 16
Sheets("main1").Copy After:=Sheets(2)
Set wTo = Worksheets(3)
wTo.Name = wFm.Range("B" & moto).Value
End If
wTo.Range("B" & saki).Value = Left(Year(wFm.Range("C" & moto).Value), 2)
wTo.Range("C" & saki).Value = Month(wFm.Range("C" & moto).Value)
wTo.Range("D" & saki).Value = Day(wFm.Range("C" & moto).Value)
wTo.Range("E" & saki).Value = wFm.Range("D" & moto).Value
wTo.Range("F" & saki).Value = wFm.Range("E" & moto).Value
wTo.Range("H" & saki).Value = wFm.Range("F" & moto).Value
If wFm.Range("G" & moto).Value > 0 Then
wTo.Range("I" & saki).Value = wFm.Range("G" & moto).Value
Else
wTo.Range("J" & saki).Value = wFm.Range("G" & moto).Value
End If
If moto > 2 Then
wTo.Range("K" & saki).Value = wFm.Range("G" & moto).Value + wTo.Range("K" & saki - 1).Value
Else
wTo.Range("K" & saki).Value = wFm.Range("G" & moto).Value
End If
saki = saki + 1
Next
mx = Range("K65536").End(xlUp).Row
Range("B16:K" & mx).Borders(xlDiagonalDown).LineStyle = xlNone
Range("B16:K" & mx).Borders(xlDiagonalUp).LineStyle = xlNone
With Range("B16:K" & mx)
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlEdgeBottom).Weight = xlThin
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeRight).Weight = xlThin
.Borders(xlInsideVertical).LineStyle = xlContinuous
.Borders(xlInsideVertical).Weight = xlHairline
.Borders(xlInsideHorizontal).LineStyle = xlContinuous
.Borders(xlInsideHorizontal).Weight = xlHairline
End With
narabe2
End Sub
受講生さんの投稿
(投稿ID: 4505) 添付ファイルのダウンロード権限がありません
お世話になっております。
昨日メールで添削を依頼しましたものを、こちらにも投稿致します。
よろしくお願い致します。
受講生さんのコメント
(コメントID: 6205)
すみません、コードで囲むのですね。
3度も投稿してしまい、申し訳ございません。
よろしくお願い致します。
小川 慶一さんのコメント
(コメントID: 6218)
改めて、こちらでも添削を公開します。
大変よく書けています。
これなら、どこでも何でも、今までに習ったスキルでできることならば、たいていのことはできるでしょう (^^
[補足]
シートに貼り付ける押下用ボタンは、「オブジェクト名」を変更可能です。
以下の手順
[1]デサインモードにする
[2]ボタンを右クリック
[3]右クリックメニューからプロパティを選択
[4]「プロパティ」のサブウィンドウが表示される
[5]「プロパティ」のサブウィンドウから、「オブジェクト名」を編集
なお、オブジェクト名を変更したら、ボタンを押したときに実行されるプロシージャは、再度作成する必要があります