mardi 24 octobre 2017

Open InputBox based on Checkbox

I'm not proficient with Excel VBA so, apologies if this sounds like an obvious question to be asked...
I'm building a model in Excel, and I'm actually trying to trigger an input box if a checkbox is checked.

So far I managed to do the following:

Private Sub Worksheet_Change(ByVal Target As Range)
    Set Target = Range("G7")

If Target.Value = "TRUE" Then

    Dim QtyEntry As Integer
    Dim Msg As String
        Msg = "Please insert value"
        QtyEntry = InputBox(Msg)
        ActiveSheet.Range("C7").Value = QtyEntry / 100
       
    End If
End Sub

The target.value G7 is the cell linked to the checkbox, so it returns TRUE when the check is on or FALSE when the check is off. However, I've two kind of problems. The first one is that the Macro doesn't actually activate when I check the checkbox (but it does if I write "TRUE" in the target cell.

The second is that when the input box appears, it correctly places the value in cell C7, but then it it keeps on asking to input values without disappearing.

Any help would be mostly appreciated!

best

Carlo




Aucun commentaire:

Enregistrer un commentaire