[[20151211151922]] 『複数のユーザーフォーム起動について』(昴) ページの最後に飛ぶ

[ 初めての方へ | 一覧(最新更新順) | 全文検索 | 過去ログ ]

 

『複数のユーザーフォーム起動について』(昴)

[[20151210140915]]
↑で飛び入りで質問しましたが
改めましたのでよろしくお願いします
列によりユーザーフォームを立ち上げ帳票を作成しようと考えています。
"A:A,E:E"にういては、セル移動でユーザーフォーム消えるのですが
H:H,I:Iは起動するのですが消えません どこか修正必要でしょうか
よろしくお願いします

Dim flag As Boolean

 Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim pos As Boolean

 If Not Intersect(Me.Range("A:A,E:E"), Target) Is Nothing Then pos = True

    If pos Then
        If Not flag Then
            UserForm4.Show vbModeless
            flag = True
            'AppActivate ActiveWindow.Caption    '★
        End If
    Else
        If flag Then
            UserForm4.Hide
            flag = False
        End If
    End If

 If Not Intersect(Me.Range("H:H"), Target) Is Nothing Then pos = True

    If pos Then
        If Not flag Then
            UserForm10.Show vbModeless
            flag = True
            'AppActivate ActiveWindow.Caption    '★
        End If
    Else
        If flag Then
            UserForm10.Hide
            flag = False
        End If
    End If

 If Not Intersect(Me.Range("I:I"), Target) Is Nothing Then pos = True

    If pos Then
        If Not flag Then
            UserForm12.Show vbModeless
            flag = True
            'AppActivate ActiveWindow.Caption    '★
        End If
    Else
        If flag Then
            UserForm12.Hide
            flag = False
        End If
    End If
 End Sub

< 使用 Excel:Excel2013、使用 OS:Windows7 >


Dim flag1 As Boolean
Dim flag2 As Boolean
Dim flag3 As Boolean

 Private Sub Worksheet_SelectionChange(ByVal Target As Range)
   Dim pos1 As Boolean
   Dim pos2 As Boolean
   Dim pos3 As Boolean

 If Not Intersect(Me.Range("A:A,E:E"), Target) Is Nothing Then pos1 = True

    If pos1 Then
        If Not flag1 Then
            UserForm4.Show vbModeless
            flag1 = True
            'AppActivate ActiveWindow.Caption    '★
        End If
    Else
        If flag1 Then
            UserForm4.Hide
            flag1 = False
        End If
    End If

 If Not Intersect(Me.Range("H:H"), Target) Is Nothing Then pos2 = True

    If pos2 Then
        If Not flag2 Then
            UserForm10.Show vbModeless
            flag2 = True
            'AppActivate ActiveWindow.Caption    '★
        End If
    Else
        If flag2 Then
            UserForm10.Hide
            flag2 = False
        End If
    End If

 If Not Intersect(Me.Range("I:I"), Target) Is Nothing Then pos3 = True

    If pos3 Then
        If Not flag3 Then
            UserForm12.Show vbModeless
            flag3 = True
            'AppActivate ActiveWindow.Caption    '★
        End If
    Else
        If flag3 Then
            UserForm12.Hide
            flag3 = False
        End If
    End If
 End Sub
(mm) 2015/12/11(金) 16:13

(mm)さん
ありがとうございます。
1個1個に独立したか立ち出ないといけないのですね。
わかりました 解決です。
(昴) 2015/12/11(金) 16:54

コメント返信:

[ 一覧(最新更新順) ]


YukiWiki 1.6.7 Copyright (C) 2000,2001 by Hiroshi Yuki. Modified by kazu.