Private Sub CommandButton15_Click() '2の1 学年末個人成績表印刷 Dim mybtn As Integer, myMsg As String, myTitle As String Dim dataRange1 As Object, hyouForm As Object Dim dataRange0 As Object, dataRange2 As Object, dataRange3 As Object, dataRange4 As Object Set hyouForm = Sheets("個人成績表") Set dataRange0 = Worksheets("基本データ").Range("Data0") Set dataRange1 = Worksheets("2の1").Range("Data11") Set dataRange2 = Worksheets("2の1 (2)").Range("Data112") Set dataRange3 = Worksheets("2の1 (3)").Range("Data113") Set dataRange4 = Worksheets("2の1 (4)").Range("Data114") maxrec% = 2 'maxrec% = 39 myTitle = "確認" myMsg = "2の1の個人成績表を印刷します。" + Chr(13) + "プリンタの準備はよろしいですか?" mybtn = MsgBox(myMsg, vbYesNo + vbExclamation, myTitle) If mybtn = vbYes Then hyouForm.Cells(8, 11).Value = "2の1" hyouForm.Cells(9, 11).Value = "" hyouForm.Cells(9, 13).Value = dataRange0.Cells(13, 4).Value For rec% = 1 To maxrec% For nn% = 1 To 15 x% = 3 + nn% hyouForm.Cells(18, x%).Value = "" hyouForm.Cells(19, x%).Value = "" hyouForm.Cells(20, x%).Value = "" hyouForm.Cells(21, x%).Value = "" Next nn% If dataRange1.Cells(rec%, 2).Value <> "" Then hyouForm.Cells(8, 16).Value = dataRange1.Cells(rec%, 2).Value hyouForm.Cells(9, 16).Value = "" hyouForm.Cells(9, 18).Value = dataRange4.Cells(rec%, 18).Value For nn% = 1 To 15 x% = 3 + nn% hyouForm.Cells(18, x%).Value = dataRange1.Cells(rec%, 2 + nn%).Value hyouForm.Cells(19, x%).Value = dataRange2.Cells(rec%, 2 + nn%).Value hyouForm.Cells(20, x%).Value = dataRange3.Cells(rec%, 2 + nn%).Value hyouForm.Cells(21, x%).Value = dataRange4.Cells(rec%, 2 + nn%).Value Next nn% 'ActiveWindow.SelectedSheets.PrintOut Copies:=1 End If Next rec% End If Range("A1").Select End Sub
© Copyright 2024 ExpyDoc