title: How do I check if a button exists if I don't know the name?
body: <p>Is there a way to see if a button exists on a worksheet if I don't know the name?</p>
  
  <p>I have code in "ThisWorkbook" that creates a button when the workbook is opened. However, I don't want it to create a button if the button is already there. So I need a way to detect if the button exists.</p>
  
  <p>I had another way around this which didn't work, which I'll include just because!</p>
  
  <p>The button, when clicked, creates a new worksheet, titled "Transpose Data". So if the button is there, that worksheet is there too. So I tried the following sub:</p>
  
  <pre><code>Private Sub Workbook_Open()
      Dim btn As Button
      Dim rng As Range
  
      On Error GoTo Errorhandler
          Sheets("Transposed Data").Activate
  
  Errorhandler:
      MsgBox ("ERROR")
      With Worksheets("Program Sheet")
          Set rng = .Range("A4:C4")
          Set btn = .Buttons.Add(rng.Left, rng.Top, rng.Width, rng.Height)
          With btn
              .Caption = "Click here to continue"
              .AutoSize = True
              .OnAction = "TableCreation"
          End With
      End With
  End Sub
  </code></pre>
  
  <p>I think this code should only create the button if it finds the transposed data worksheet isn't there, which is exactly what I want. However, this code just signifies an error every single time I try to run it. I've tested all of the parts individually, and they work, so I'm not sure what the problem is.</p>
  
  <p>But, if there's a different way to detect if a button is already in a worksheet, I don't need this, because I can simply create an if/then statement!</p>