Forum Discussion

Andy8's avatar
Andy8
Copper Contributor
Sep 15, 2025
Solved

Toggle Button Code

Hi

I have the below code in a toggle button which places an ‘X’ in the active cell which could be anywhere on the spreadsheet. 

Private Sub ToggleButton1_Click()
          If ActiveCell.Value = "X" Then
            ActiveCell.Value = ""
          Else
            ActiveCell.Value = "X"
          End If
        End Sub

 

Is there a change to the code I can make to force the toggle button to place/remove the ‘X’ from specifically cell ‘C3’?

Many Thanks

 

Andy

  • Attached is a code example in the attached file.

    It should work in Excel 2016 and Excel 365.

     

    My answers are voluntary and without guarantee!

     

    Hope this will help you.

     

    Was the answer useful? Mark as best response and like it!

    This will help all forum participants.

2 Replies

  • NikolinoDE's avatar
    NikolinoDE
    Gold Contributor

    Attached is a code example in the attached file.

    It should work in Excel 2016 and Excel 365.

     

    My answers are voluntary and without guarantee!

     

    Hope this will help you.

     

    Was the answer useful? Mark as best response and like it!

    This will help all forum participants.

    • Andy8's avatar
      Andy8
      Copper Contributor

      Hi Nikolino

      Thats brilliant,  exactly what I was needing!!

      Sorry for the delay in replying - Microsoft had put a block on the file and it took me a while to work out how to clear it!  

       

      Thanks very much for your solution

      Chers

      Andy

       

       

Resources