エクセルvbaでチェックしたシートを印刷する

2014年6月13日金曜日

MicrosoftOffice

t f B! P L
メモ


'標準モジュールでユーザーフォームの表示
Sub START()

    UserForm1.Show
    
End Sub



' シート名のチェックボックスを作成するボタン
Private Sub CommandButton1_Click()
    Dim s As Integer
    Dim myCheckBox As Control
    
    For s = 1 To Sheets.Count
        Set myCheckBox = Me.Controls.Add("Forms.CheckBox.1")
        With myCheckBox
            .Height = 20
            .Width = 132
            .Left = 10
            .Top = (s - 1) * .Height + 10
            .Caption = Sheets(s).Name
        End With
    Next s
End Sub

' チェックしたシートを印刷するボタン
Private Sub CommandButton2_Click()
    Dim mch As Control
    
    For Each mch In Controls
        If TypeName(mch) = "CheckBox" Then
            If mch.Value = True Then
                Sheets(mch.Caption).PrintOut
            End If
        End If
    Next mch
    
End Sub


Translate

このブログを検索

  • ()
  • ()
もっと見る

QooQ