問題があります。セルの値に応じてボタンを有効/無効にする方法。
Excelシートには2つのボタンがあります。
私がしなければならないことは.
列「L」にデータがある場合
ワンボタンで有効化
そうしないと
「BQ」はデータを持っています
別のボタンを有効にする必要があります。その他のボタンは無効になります。
それを達成する方法。
助けてください....よろしくお願いします
両方とも埋まったらどうなるか、あなたの返事を待っていました。そのオプションをコードに追加しました。必要に応じて修正してください。
これを試して
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo Whoa
    Application.EnableEvents = False
    CommandButton1.Enabled = False: CommandButton2.Enabled = False
    '~~> If both cols are filled up
    If Application.WorksheetFunction.CountA(Columns(12)) > 0 And _
    Application.WorksheetFunction.CountA(Columns(69)) > 0 Then
        '~~> Change the message as applicable
        MsgBox "Both Columns Cannot have data", vbInformation, "Error"
    Else
        '~~> If Col L is filled up
        If Application.WorksheetFunction.CountA(Columns(12)) > 0 _
        Then CommandButton1.Enabled = True
        '~~> If Col BQ is filled up
        If Application.WorksheetFunction.CountA(Columns(69)) > 0 _
        Then CommandButton2.Enabled = True
    End If
LetsContinue:
    Application.EnableEvents = True
    Exit Sub
Whoa:
    MsgBox Err.Description
    Resume LetsContinue
End Sub
CommandButton1とCommandButton2を、ボタンの名前に置き換えます。
Private Sub Worksheet_Change(ByVal Target As Range)
    If Application.WorksheetFunction.CountA(Range("L:L")) > 0 Then
        CommandButton1.Enabled = True
    Else
        CommandButton1.Enabled = False
    End If
    If Application.WorksheetFunction.CountA(Range("BQ:BQ")) > 0 Then
        CommandButton1.Enabled = False
        CommandButton2.Enabled = True
    Else
        CommandButton1.Enabled = True
    CommandButton2.Enabled = False
End If
End Sub