+ Reply to Thread
Results 1 to 5 of 5

IF statement is not working as expected?

  1. #1
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    854

    Question IF statement is not working as expected?

    Hi All,
    If the "Summary" sheet contains a chart, the chart must be deleted when I click the ViewSummary button. The code below does not achieve this and I can't figure it out? Please help.

    Please Login or Register  to view this content.
    Thank You
    Last edited by Aland2929; 07-31-2009 at 02:03 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    re: IF statement is not working as expected?

    Hello Aland2929,

    If you have only one chart on the sheet you want to delete, you can it much more easily this way...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    854

    re: IF statement is not working as expected?

    Hi Leith,
    Thanks for your response. I have another button on the summary sheet to create the chart. When I click the ViewSummary button it needs to check if there is a chart and if there is, it must delete the chart. If there is no chart, then it must not attempt to delete a chart because this results in an error?
    This is why I tried the IF construct. Hope you can help with this.
    Thank You.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    re: IF statement is not working as expected?

    Hello Aland2929,

    This will check if the chart exists. If it does it will delete it.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    854

    re: IF statement is not working as expected?

    Thank you Leith. Your code has solved my problem. There was a "t" missing from the following line of code ".CharObjects(1).Delete", which I initially missed. I also had to activate the "Summary" sheet. Thanks for your quick response.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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