+ Reply to Thread
Results 1 to 8 of 8

Code to check if form object (shape) exists not working correctly?

  1. #1
    Registered User
    Join Date
    01-31-2015
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    89

    Code to check if form object (shape) exists not working correctly?

    Hi

    I am using Excell 2007 and I have a macro that performs various tasks.

    One of these tasks is to look and see if an Form Option Button named OptionButton1 exists
    and if it does it deletes it, if it does not then it displays a message box.

    From researching I have been able to come up with the code below thanks to google searches
    but when I run it with the option button on the worksheet it brings up the message box which
    is wrong as the option button DOES exist.

    Can someone kindly suggest where I am going wrong or if there is a better way?


    Please Login or Register  to view this content.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Code to check if form object (shape) exists not working correctly?

    Very high odds that it is spelled "Option Button 1" not "OptionButton1"

  3. #3
    Registered User
    Join Date
    01-31-2015
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    89

    Re: Code to check if form object (shape) exists not working correctly?

    Quote Originally Posted by davesexcel View Post
    Very high odds that it is spelled "Option Button 1" not "OptionButton1"

    Hi Dave

    When the Option Button is created by a different macro the object name property is set to OptionButton1.
    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,257

    Re: Code to check if form object (shape) exists not working correctly?

    try this
    Please Login or Register  to view this content.
    "ThankyouFor Attention * And Your Help!!"

  5. #5
    Registered User
    Join Date
    01-31-2015
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    89

    Re: Code to check if form object (shape) exists not working correctly?

    daboho,

    Thank you for your reply.

    Your code is returning every option button and group box on my worksheet and giving the message that they do not exists when they do?
    Last edited by jeffreybrown; 10-13-2018 at 12:48 PM. Reason: Removed full quote!

  6. #6
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,257
    Quote Originally Posted by Belinea2010 View Post
    daboho,

    Thank you for your reply.

    Your code is returning every option button and group box on my worksheet and giving the message that they do not exists when they do?
    Change to
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-31-2015
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    89

    Re: Code to check if form object (shape) exists not working correctly?

    Hi daboho

    I really appreciate you taking the time to help me.

    The new code is now only looking for the Option Button and displays the Has Exists message if the option box DOES exist which is but
    if the option box does NOT exist the code does not display the Not Exists message?

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Code to check if form object (shape) exists not working correctly?

    Attaching a sample workbook enables others to work on your problem:

    To attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include BEFORE/AFTER sheets if needed to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and click "manage attachments" to open the upload window.


    To add a file to a post

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA: How to check if an object already exists in worksheet or module
    By ysdai7287 in forum Excel Programming / VBA / Macros
    Replies: 31
    Last Post: 09-21-2017, 10:47 PM
  2. [SOLVED] Compile error: Member already exists in an object module...Trying to create a form
    By MonaP92 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-12-2015, 11:12 AM
  3. [SOLVED] Member already exists in an object module form which this object module derives error
    By Sc0tt1e in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-01-2014, 03:14 AM
  4. Worksheet exists........function not working correctly.
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-20-2011, 12:02 PM
  5. check if shape exists, then...
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-26-2010, 07:09 AM
  6. check if shape Exists
    By FRIEL in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-09-2009, 12:30 PM
  7. Check if a Form item exists.
    By The_Vulcan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-02-2007, 03:37 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1