Excel vba IF THEN ELSE statement

Hi.  I have two Subs:

   one inserts a shape (“Checkmark”) on top of another shape, a square, and

   one erases a shape (“Checkmark”) when it is selected.

When a user double-clicks on a particular square, one of two things must happen:

    a) If the square is empty, a checkmark gets inserted into the square;

    b) If the square already has a checkmark in it, the checkmark gets erased.

My problem is:  I’m having trouble writing an If Then Else statement that works!

       “If there’s no checkmark in the square, then insert one;

       Else

       If the square contains a checkmark, erase it.”

Both of the existing subs work properly.  And, the  _BeforeDoubleClick_ action also works fine.  But I can’t make the If Then Else statement work properly.  Help, please!  Thank you.

 

The existing subs:

     Sub EraseCheckmark()

         SendKeys “{DEL}”

      End Sub

 

Sub PlaceCheckmark()

    ActiveSheet.Shapes.Range(Array(“Checkmark”)).Select

    Selection.Copy

    ActiveCell.Offset(0, 0).Range(“A1”).Select

    ActiveSheet.Paste

    Selection.ShapeRange.IncrementLeft 0.3750393701

    Selection.ShapeRange.IncrementLeft 0.3750393701

    Selection.ShapeRange.IncrementLeft 0.3750393701

    Selection.ShapeRange.IncrementLeft 0.3750393701

    Selection.ShapeRange.IncrementLeft 0.3750393701

    Selection.ShapeRange.IncrementLeft 0.3750393701

    Selection.ShapeRange.IncrementLeft 0.3750393701

    Selection.ShapeRange.IncrementLeft 0.3750393701

    Selection.ShapeRange.IncrementLeft 0.3750393701

    Selection.ShapeRange.IncrementLeft 0.3750393701

    Selection.ShapeRange.IncrementLeft 0.3750393701

    Selection.ShapeRange.IncrementLeft 0.3750393701

    Selection.ShapeRange.IncrementTop 0.3750393701

    Selection.ShapeRange.IncrementTop 0.3750393701

    Selection.ShapeRange.IncrementTop 0.3750393701

    Selection.ShapeRange.IncrementTop 0.3750393701

    Selection.ShapeRange.IncrementTop 0.3750393701

    Selection.ShapeRange.IncrementTop 0.3750393701

    Selection.ShapeRange.IncrementTop 0.3750393701

    Selection.ShapeRange.IncrementTop 0.3750393701

    Selection.ShapeRange.IncrementTop 0.3750393701

    Selection.ShapeRange.IncrementTop 0.3750393701

    Selection.ShapeRange.IncrementTop 0.3750393701

    Selection.ShapeRange.IncrementTop 0.3750393701

    Selection.ShapeRange.IncrementTop 0.3750393701

    Selection.ShapeRange.IncrementTop 0.3750393701

    Selection.ShapeRange.IncrementTop 0.3750393701

    Selection.ShapeRange.IncrementTop 0.3750393701

    Selection.ShapeRange.IncrementTop 0.3750393701

    Selection.ShapeRange.IncrementLeft 0.3750393701

    Cancel = True

    SendKeys “{ESC}”

    newHour = Hour(Now())

    newMinute = Minute(Now())

    newSecond = Second(Now()) + 2

    waitTime = TimeSerial(newHour, newMinute, newSecond)

    Application.Wait waitTime

End Sub

By: Robin Miller

42 thoughts on “Excel vba IF THEN ELSE statement

  1. yeezy boost 350

    I would like to express my thanks to the writer just for bailing me out of this particular setting. After surfing through the world wide web and coming across methods that were not helpful, I assumed my life was well over. Being alive without the presence of approaches to the issues you have resolved by means of your review is a crucial case, and the ones which may have in a negative way affected my entire career if I had not noticed your site. Your own personal skills and kindness in handling all areas was very useful. I am not sure what I would’ve done if I had not encountered such a subject like this. I’m able to at this time look forward to my future. Thanks for your time very much for this impressive and results-oriented guide. I will not think twice to suggest your web blog to any individual who needs to have guide on this problem.

  2. nike air max

    Thank you a lot for providing individuals with an extremely memorable possiblity to read from this blog. It is always so kind plus stuffed with fun for me personally and my office acquaintances to visit your site at minimum three times weekly to read the latest issues you have got. Not to mention, I am just actually satisfied with the impressive suggestions served by you. Selected 1 tips in this article are in truth the most impressive we’ve had.

  3. ig

    Wonderful site. Plenty of useful info here. I’m sending it to a few friends ans additionally sharing in delicious.
    And certainly, thank you on your sweat!

  4. Wendy

    Thanks for the good writeup. It in fact used to be a leisure
    account it. Glance complicated to far added agreeable from
    you! However, how could we be in contact?

  5. cheap jordans

    I wish to show some appreciation to the writer for rescuing me from this issue. Just after browsing throughout the world wide web and meeting suggestions that were not productive, I figured my entire life was gone. Being alive without the presence of solutions to the problems you have fixed by means of your report is a serious case, as well as ones which may have badly affected my entire career if I hadn’t come across your web blog. Your main mastery and kindness in handling the whole lot was excellent. I am not sure what I would have done if I had not come upon such a stuff like this. I am able to now look ahead to my future. Thanks so much for the specialized and effective help. I won’t be reluctant to refer your blog to any individual who wants and needs direction on this subject.

  6. birkin bag

    Thank you so much for providing individuals with remarkably terrific possiblity to discover important secrets from here. It is usually very lovely and packed with amusement for me and my office peers to visit your website no less than three times every week to find out the newest tips you have got. And of course, I’m just certainly motivated with the beautiful thoughts served by you. Certain 4 ideas in this post are honestly the most effective I have ever had.

  7. sling tv

    Oh my goodness! Awesome article dude! Many thanks, However
    I am experiencing troubles with your RSS.
    I don’t understand the reason why I can’t subscribe to it.
    Is there anyone else getting the same RSS problems?

    Anybody who knows the answer will you kindly respond?

    Thanx!!

  8. off white

    I as well as my pals have already been studying the best tips and tricks located on your web site while then developed an awful suspicion I never expressed respect to the web site owner for those tips. The boys had been absolutely glad to see them and now have in actuality been enjoying these things. I appreciate you for genuinely well considerate as well as for deciding upon these kinds of superior subjects millions of individuals are really wanting to learn about. Our own sincere regret for not expressing gratitude to sooner.

  9. kate spade handbags

    I simply wanted to appreciate you again. I’m not certain what I might have worked on in the absence of those suggestions shown by you over such a situation. It previously was a very horrifying situation in my circumstances, but being able to see this professional way you managed that forced me to leap over contentment. I am grateful for the help as well as trust you are aware of a powerful job you have been providing teaching most people with the aid of a web site. Most likely you have never got to know all of us.

  10. lebron 17

    Thanks for all of the effort on this site. My aunt take interest in managing investigation and it is easy to see why. Most of us hear all of the powerful mode you give useful ideas via this web blog and inspire participation from website visitors on that area of interest so our favorite girl is actually studying a great deal. Enjoy the rest of the year. You are carrying out a fabulous job.

  11. sling tv

    Hello to every one, because I am actually keen of reading this website’s post to be updated on a
    regular basis. It includes fastidious information.

  12. yeezy sneakers

    Thank you a lot for providing individuals with remarkably terrific opportunity to read articles and blog posts from this web site. It is always very ideal and also jam-packed with fun for me and my office mates to search your blog nearly 3 times weekly to find out the latest secrets you will have. Of course, I’m just usually impressed concerning the tremendous tips served by you. Some 3 tips in this posting are without a doubt the most suitable we have had.

  13. sling tv

    Hi there, this weekend is pleasant designed for me, because this point in time i am reading this impressive informative paragraph here
    at my residence.

  14. adidas stan smith

    I really wanted to write a brief message to be able to appreciate you for some of the precious items you are sharing at this site. My time consuming internet research has at the end of the day been compensated with beneficial facts to share with my relatives. I ‘d believe that many of us site visitors actually are undoubtedly lucky to live in a fine site with so many marvellous individuals with helpful hints. I feel quite blessed to have used the web page and look forward to so many more fabulous moments reading here. Thanks once again for a lot of things.

  15. adidas tubular shadow

    I have to point out my respect for your generosity supporting men who actually need help on this one concern. Your real dedication to getting the message across ended up being incredibly powerful and have regularly encouraged professionals like me to get to their pursuits. Your personal helpful facts can mean a whole lot a person like me and substantially more to my office colleagues. Best wishes; from each one of us.

  16. asksylphoflight sling tv

    Hi, Neat post. There’s a problem along with your website in internet explorer, may test this?
    IE still is the marketplace leader and a good
    part of folks will pass over your great writing due to
    this problem.

  17. timberland

    I simply wanted to write a simple message to thank you for some of the awesome tips and hints you are placing at this website. My time intensive internet research has finally been honored with good tips to share with my co-workers. I would assume that we visitors actually are quite blessed to dwell in a wonderful network with so many outstanding people with beneficial techniques. I feel pretty fortunate to have used your website page and look forward to some more amazing times reading here. Thanks a lot again for all the details.

  18. match.com free trial

    This design is spectacular! You obviously know how to keep a reader amused.
    Between your wit and your videos, I was almost
    moved to start my own blog (well, almost…HaHa!) Fantastic job.
    I really loved what you had to say, and more than that, how
    you presented it. Too cool!

  19. supreme clothing

    I wanted to write you the very small note in order to give many thanks over again for your personal gorgeous tips you’ve shared in this case. This is really extremely open-handed of you to convey openly all a lot of folks could possibly have supplied for an electronic book to end up making some bucks for their own end, specifically considering that you might have tried it in the event you wanted. The secrets as well worked to provide a fantastic way to know that other individuals have similar keenness like my personal own to know lots more in respect of this issue. I’m certain there are numerous more fun instances up front for those who go through your blog.

  20. kyrie 6

    Needed to post you the very little word just to say thanks the moment again regarding the exceptional opinions you have contributed at this time. This is quite strangely open-handed with you to allow easily what exactly a few people might have made available as an ebook to help with making some money for their own end, particularly seeing that you might well have done it if you wanted. Those suggestions also worked to become great way to fully grasp the rest have a similar dreams like my personal own to know the truth a lot more with regard to this problem. I’m sure there are some more enjoyable times up front for those who browse through your website.

  21. yeezy boost

    My wife and i were really comfortable Jordan could finish off his survey through your precious recommendations he had in your web page. It is now and again perplexing to just continually be freely giving information a number of people have been trying to sell. We really see we’ve got the blog owner to thank for this. All the illustrations you made, the simple blog navigation, the relationships you will help engender – it is most impressive, and it’s really helping our son in addition to us know that the matter is cool, which is certainly truly fundamental. Thanks for all!

  22. coconut oil

    Hey I am so delighted I found your weblog, I really found you by mistake, while
    I was looking on Aol for something else, Nonetheless I am here now and would just like to say kudos for a fantastic post and a all round interesting blog (I also love the theme/design), I
    don’t have time to browse it all at the moment but I have
    book-marked it and also added in your RSS feeds, so when I have time I will
    be back to read much more, Please do keep up the excellent jo.

  23. Leatrice Ibasitas

    Oh my goodness! an amazing article dude. Thank you However I am experiencing issue with ur rss . Don?t know why Unable to subscribe to it. Is there anyone getting identical rss problem? Anyone who knows kindly respond. Thnkx

  24. quest bars cheap

    I don’t know if it’s just me or if everybody else encountering problems
    with your site. It appears as if some of the text in your posts are running off the screen.
    Can someone else please comment and let me know if this is happening to them too?

    This could be a issue with my web browser because I’ve had
    this happen before. Thanks

  25. quest bars cheap

    Hi there, I think your site could be having web browser compatibility problems.
    Whenever I look at your site in Safari, it looks fine however, when opening in Internet Explorer, it
    has some overlapping issues. I just wanted to give you
    a quick heads up! Apart from that, fantastic website!

  26. ps4 games

    What i don’t understood is actually how you are now not really much more smartly-liked than you might
    be now. You’re so intelligent. You already know therefore
    significantly relating to this matter, produced me individually
    believe it from a lot of numerous angles. Its like men and women are not interested unless it is one thing to do with Lady gaga!
    Your individual stuffs excellent. At all times deal with
    it up!

  27. ps4 games

    Great site. Lots of useful information here. I am
    sending it to several buddies ans also sharing in delicious.
    And naturally, thanks on your sweat!

  28. kobe 11

    An fascinating discussion is worth comment. I think that it’s best to write more on this topic, it may not be a taboo subject but typically people are not sufficient to talk on such topics. To the next. Cheers

  29. quest bars cheap coupon twitter

    Howdy! I know this is somewhat off topic but I was wondering which blog platform
    are you using for this website? I’m getting sick and
    tired of WordPress because I’ve had issues with hackers and I’m looking at options
    for another platform. I would be awesome if you could point me
    in the direction of a good platform.

  30. quest bars cheap

    That is really fascinating, You are an overly professional blogger.

    I have joined your rss feed and stay up for searching
    for more of your magnificent post. Also, I have shared your web site
    in my social networks

  31. supreme clothing

    There are actually loads of details like that to take into consideration. That is a nice level to deliver up. I offer the thoughts above as normal inspiration but clearly there are questions like the one you bring up the place crucial factor will probably be working in honest good faith. I don?t know if finest practices have emerged around issues like that, but I’m sure that your job is clearly recognized as a good game. Each girls and boys really feel the impact of only a second抯 pleasure, for the remainder of their lives.

  32. air max 270

    The subsequent time I read a blog, I hope that it doesnt disappoint me as a lot as this one. I imply, I do know it was my option to learn, however I truly thought youd have one thing fascinating to say. All I hear is a bunch of whining about something that you possibly can fix in case you werent too busy on the lookout for attention.

  33. fila online shop

    Aw, this was a really nice post. In idea I want to put in writing like this moreover ?taking time and precise effort to make an excellent article?but what can I say?I procrastinate alot and certainly not appear to get one thing done.

  34. tinyurl.com

    Thank you for any other informative blog. Where else could I get that type of information written in such
    a perfect means? I’ve a project that I’m just now running on,
    and I’ve been at the look out for such info.

  35. curry 4 shoes

    I am often to running a blog and i really admire your content. The article has actually peaks my interest. I am going to bookmark your web site and maintain checking for new information.

Comments are closed.