VBA - How to test if a text box is present on the sheet or not?

  • Thread starter Thread starter Frank Krogh
  • Start date Start date
F

Frank Krogh

I have made a command button on the sheet that shows a text box with help
info.

How do I test if the text box with a given name is already present in the
sheet or not - to avoid creating several instances of the text box?


Frank Krogh
 
Hi Frank,

Here's some sample code

Dim txt As OLEObject

On Error Resume Next
Set txt = ActiveSheet.OLEObjects("TextBox2")
On Error GoTo 0
If Not txt Is Nothing Then
MsgBox "Already exists"
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top