1 2 3 4 5 6 7 9 10 11
1 7 1 126 Microsoft Excel VBA Microsoft Excel VBA 127
Sub () ' ' []A2 A3A19 ' B19C19 ' ' []ABC ' DE ' ' ' [] ' ' [] ' ' Dim KaisyaName As String ' Dim TantouName As String ' Dim ShouhinName As String ' Dim Tanka As Long ' Dim ChumonSuu As Integer ' Dim IchiranGyo As Long Dim SeikyuGyo As Integer Dim InsatsuYN As Integer For IchiranGyo = 2 To 65536 ' [] ' [] ' ' [] Sheets("").Select A' [] ' Range("A" & IchiranGyo).Select ' KaisyaName KaisyaName = Selection.Value Range("B" & IchiranGyo).Select TantouName = Selection.Value Range("C" & IchiranGyo).Select ShouhinName = Selection.Value Range("D" & IchiranGyo).Select Tanka = Selection.Value Range("E" & IchiranGyo).Select ChumonSuu = Selection.Value ' TantouName ' ShouhinName ' Tanka ' ChumonSuu 1 2 3 4 5 ' [][] Sheets("").Select Range("A2").Select ' [] ' A2 If Selection.Value <> KaisyaName Then ' ' A2 ' ' [] ' InsatsuYN = MsgBox("?", vbyesnocancel) If InsatsuYN = vbcancel Then Exit For If InsatsuYN = vbyes Then ActiveWindow.SelectedSheets.PrintOut Copies=1B ' Range("A19C42").Select C Selection.ClearContents ' 19 SeikyuGyo = 19 Range("A2").Select A Selection.Value = KaisyaName 'A2 Range("A3").Select 'A3 Selection.Value = TantouName & " " Range("A" & SeikyuGyo).Select 'ASeikyuGyo Selection.Value = ShouhinName Range("B" & SeikyuGyo).Select 'BSeikyuGyo Selection.Value = Tanka Range("C" & SeikyuGyo).Select 'CSeikyuGyo Selection.Value = ChumonSuu SeikyuGyo = SeikyuGyo + 1 Next IchiranGyo MsgBox "!" End End Sub '()!0 7 23 9!1 If KaisyaName = "" Then Exit For ' ' 6 1 12 Microsoft Excel VBA Microsoft Excel VBA 129
3 Dim SeikyuGyo1 Dim 2 ForNextIchiranGyo1 For For IchiranGyo2 For265536 If 11 4 Sheets(""). SelectRange("A" & "IchiranGyo").SelectIchiranGyo A = Selection.Value 3 1 5 2 A B DelC 46 130 Microsoft Excel VBA Microsoft Excel VBA 131
2 DimAs 71 Dim KaisyaName As String ' Dim TantouName As String ' Dim ShouhinName As String ' Dim Tanka As Long ' Dim ChumonSuu As Integer ' DimAs DimAs DimAs VBA Dim KaisyaName As StringKaisyaNameString Dim ChumonSuu As Integer Enter Enter 62 Dim u 1 ChumonSuuInteger 1 Dim KaisyaName As String, TantouName As String, ShouhinName As String 132 Microsoft Excel VBA Microsoft Excel VBA 133
3 Sheets().SelectSelection.Value Excel2 Sheets()Worksheets()Charts() Sheets() Sheets("").Select Range("A" & IchiranGyo).Select KaisyaName = Selection.Value ' [] ' KaisyaName Sheets().Select Range().SelectA 7A1A2A3 Sheets().Select Sheets().Select Range("A" & IchiranGyo).Select Range() " String 1 A10 Range("A10").Select [A10].Select A10B15 Range("A10B15").Select [A10B15].Select Range("").Select.Select = Selection.Value Selection.Value Range().Select KaishaName Sheets("").Select Range("A" & IchiranGyo).Select KaisyaName = Selection.Value 134 Microsoft Excel VBA Microsoft Excel VBA 135
4 If ThenElse AXBY If TrueFalse If Selection.Value <> KaisyaName Then ' ' Range("A19C42").Select Selection.ClearContents ' 19 SeikyuGyo = 19 Tokuten10050 If Tokuten = 100 Then MsgBox "" If Tokuten <= 50 Then MsgBox "" If ThenElse IfThenIfThen If Then End If Else If Then Else If Tokuten = 100 Then MsgBox "" Else MsgBox "" Tokuten100 6060 If Tokuten < 60 Then MsgBox "" Else MsgBox "" 136 Microsoft Excel VBA Microsoft Excel VBA 137
If If 2If X If Selection.Value <> KaisyaName Then ' ' A2 ' = If X = 100 Then X100 > If X > 100 Then X100 < If X < 100 Then X100 >= If X >= 100 Then X100 <= If X <= 100 Then X100 <> If X <> 100 Then X100 2 ' [] ' InsatsuYN = MsgBox("?", vbyesnocancel) If InsatsuYN = vbcancel Then Exit For If InsatsuYN = vbyes Then ActiveWindow.SelectedSheets.PrintOut Copies=1 ' Range("A19C42").Select Selection.ClearContents If X < 100 Then If 100 > X Then ' 19 SeikyuGyo = 19 NameString If If Name = "" Then If Name <> "" Then 1 2 Name If Selection.Value <> KaisyaName Then ' ' KaisyaName 1If 124 MsgBox "" Range("A19C42").Select Selection.ClearContents SeikyuGyo = 19 (A19C42) 2 SeikyuGyo19 4 1 3 IfA2 KaisyaName KaisyaName A2If A2KaisyaName 13 Microsoft Excel VBA Microsoft Excel VBA 139
5 ForExit For To For IchiranGyo = 2 To 65536 Exit For For Next IchiranGyo Exit For ForNextNextExit For A19C42 SeikyuGyo 19 For IchiranGyo = 2 To 65536 If KaisyaName = "" Then Exit For Next IchiranGyo MsgBox "!" KaisyaName Exit For For 140 Microsoft Excel VBA Microsoft Excel VBA 141
6 MsgBox MsgBox MsgBoxIf InsatsuYN = MsgBox("?",vbYesNoCancel) MsgBox "!" MsgBox MsgBox (,,) MsgBox MsgBox VBA MsgBox vbokonly 0 vbokcancel 1 vbabortretrylgnore 2 vbyesnocancel 3 vbyesno 4 vbretrycancel 5 OK MsgBoxIf MsgBox If Microsoft Excel InsatsuYN = MsgBox("?", vbyesnocancel) '[] If InsatsuYN = vbcancel Then Exit For '[] If InsatsuYN = vbyes Then ActiveWindow.SelectedSheets.PrintOut Copies=1 142 Microsoft Excel VBA Microsoft Excel VBA 143
IfEnd If 1 \ Next 3 IfMsgBox \ 2 InsatsuYNInteger InsatsuYN = MsgBox("?", vbyesnocancel) \ 2 2 A19C42 InsatsuYN 3 vbcancel2vbyes6 vbno7 If 4 19 vbok 1 vbcancel 2 vbabort 3 vbretry 4 vbignore 5 vbyes 6 vbno 7 144 Microsoft Excel VBA Microsoft Excel VBA 145
7 ActiveWindow.SelectedSheets.PrintOut ActiveWindow.SelectedSheets.PrintOut ActiveWindow.SelectedSheets.PrintOut Copies=1 Activewindow.SelectedSheets Copies Copies 1 From From To To PrintOut.PrintOut CopiesFromTo PrintOut ActiveWindow.SelectedSheets.PrintOut Copies=1 With ActiveSheet.PageSetup.LeftHeader = "".CenterHeader = "".RightHeader = "".BlackAndWhite = False.Zoom = 100.PrintErrors = xlprinterrorsdisplayed End With 146 Microsoft Excel VBA Microsoft Excel VBA 147
Selection.ClearContents 9 Selection.Value Selection.Clearcontetns Del Selection.ValueSelection.Value Range("A19C42").Select Selection.ClearContents 'A2KaisyaName Range("A2").Select Selection.Value = KaisyaName Range().SelectSelection.ClearContents Range().SelectSelection.ClearContents Range().Select Selection.ClearContents ClearContents Selection.Clear Worksheets("").Range("A19C42").ClearContents Selection.Value Selection.Value 10050.50 Selection.Value "1,005,050" Selection.Value "2002/11/27" Selection.Value "045030" Selection.Value "Asaka" 14 Microsoft Excel VBA Microsoft Excel VBA 149
10 2 Value 2IchiranGyo SeikyuGyo1IchiranGyoFor 1SeikyuGyo 1 IchiranGyo Range().SelectSelection.Value 'A2KaisyaName Range("A2").Select Selection.Value = KaisyaName 'A3TantouName Range("A3").Select Selection.Value = TantouName & " " 'ASeikyuGyoShouhinName Range("A" & SeikyuGyo).Select Selection.Value = ShouhinName 'BSeikyuGyoTanka Range("B" & SeikyuGyo).Select Selection.Value = Tanka 'CSeikyuGyoChumonSuu Range("C" & SeikyuGyo).Select Selection.Value = ChumonSuu For IchiranGyo = 2 To 65536 Sheets("").Select Range("C" & IchiranGyo).Select ShouhinName = Selection.Value Range("D" & IchiranGyo).Select Tanka = Selection.Value Next IchiranGyo +1 150 Microsoft Excel VBA Microsoft Excel VBA 151
For SeikyuGyo 1SeikyuGyo1SeikyuGyo 1 19 SeikyuGyoSeikyuGyo1 SeikyuGyo11 11 End End Sub () End End Sub End End End End SubEnd Function If Selection.Value <> KaisyaName Then SeikyuGyo = 19 Sheets("").Select Range("A" & SeikyuGyo).Select Selection.Value = ShouhinName SeikyuGyo = SeikyuGyo + 1 +1 9 EndEnd End Visual Basic Editor 53 152 Microsoft Excel VBA Microsoft Excel VBA 153
C Len Len() Right\ c = Right(FolderName, 1) If c <> "\" Then FolderName = FolderName & "\" End if 154 1 InputBox MidFor 1 For i=1 To Len(Moji) c = Mid(Moji, i, 1) Next i Moji1 c LeftRight Left, Right, Left Right 0"" Left c = Left(Moji, 1) If c = "" Then MsgBox "" Microsoft Excel VBA Mid Mid,, 1 11, Len LCaseUCase LCase UCase LCaseUCase Chk1 = UCase(Code) Chk2 = Ucase(DBCode) If Chk1 = Chk2 Then MsgBox ""