+ Reply to Thread
Results 1 to 15 of 15

Script to have your form check the contents of a cell and reply different results

  1. #1
    Registered User
    Join Date
    12-02-2013
    Location
    London, UK
    MS-Off Ver
    Excel 2011 Mac
    Posts
    17

    Script to have your form check the contents of a cell and reply different results

    Hi all.

    I have a form with two text fields, "txtDate" and "txtStaffNumber".

    When the "cmdSend" button is pressed, the script needs to find that date entered, go along the row to cell O which will either contain a 0, 1, 2, 3 or 4. I need the following results to display back on the form if the cell contains certain numbers...

    If 0, then a label box saying UNAVAILABLE and thats it.

    If 1, 2, 3 or 4, label box saying AVAILABLE and a button to appear next to it "cmdBook", (which I already have the code for what I want that to do.)

    I'm guessing it will be done by entering the labels and button before, hiding them and then unhide if the result is in the right parameter, but I don't know how.

    Can anyone help please?

    Many thanks.

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Script to have your form check the contents of a cell and reply different results

    Quote Originally Posted by steve_from_the_uk View Post
    go along the row to cell O which will either contain a 0, 1, 2, 3 or 4
    I'm assuming you are refering to Column "O" in the same row as the date is found? Are the dates found in column A?
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Registered User
    Join Date
    12-02-2013
    Location
    London, UK
    MS-Off Ver
    Excel 2011 Mac
    Posts
    17

    Re: Script to have your form check the contents of a cell and reply different results

    Hi Solus.

    Yes, I'm sorry, I did mean 'Column O'. And yes the dates are in 'Column A'

    Thanks.

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Script to have your form check the contents of a cell and reply different results

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-02-2013
    Location
    London, UK
    MS-Off Ver
    Excel 2011 Mac
    Posts
    17

    Re: Script to have your form check the contents of a cell and reply different results

    Hiya!

    Thanks for your reply. I have only just had a chance to have a go at it. Unfortunately it doesn't seem to work. I have tried fiddling about with it but it just doesn't seem to work. It does hide the cmdBook, but if you put text in and hit cmdSend, it does nothing. But if you press cmdSend with nothing in the text boxes, it comes back 'unavailable'. Any ideas??

    I will attach a copy of the document so you can see what I mean.

    Many thanks.
    Steve.
    Attached Files Attached Files

  6. #6
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Script to have your form check the contents of a cell and reply different results

    See if this works. I didn't know the values were generated from formulas.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-02-2013
    Location
    London, UK
    MS-Off Ver
    Excel 2011 Mac
    Posts
    17

    Re: Script to have your form check the contents of a cell and reply different results

    Hi Solus, works great!! Thank you. Apologies for not telling you that the cell was a formula.

    Just one small thing, and probably a small fix, but when I run the form and press send, I get a Run-time error 13: Type mismatch and after clicking debug, the following line gets highlighted as the problem...

    Please Login or Register  to view this content.
    I have tried finding out what the error is and from what I've read on the net it is a problem with a value in the spreadsheet, however the only thing that I can see that it might be, is that cell A1 is a heading 'Date' (the site I read from started going into strings, integers, numbers, etc etc which is where I got lost) but thought maybe its this?

    Thanks again Solus, Steve.

  8. #8
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Script to have your form check the contents of a cell and reply different results


  9. #9
    Registered User
    Join Date
    12-02-2013
    Location
    London, UK
    MS-Off Ver
    Excel 2011 Mac
    Posts
    17

    Re: Script to have your form check the contents of a cell and reply different results

    Hiiiiiiiiii.

    I don't know what its missing, but when I downloaded it and tried to run it, I get a compile error, could not find project or library. Also on the form there txtDate box has diasappeared, but then looking through the new script, I can't see any mention of it so presume you replaced it with something else, which for some reason, isn't coming accross on the file.

    What did you replace txtDate with?

  10. #10
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Script to have your form check the contents of a cell and reply different results

    I'm sorry I did not realize you were on mac. That solution may only be suitable for PC.

  11. #11
    Registered User
    Join Date
    12-02-2013
    Location
    London, UK
    MS-Off Ver
    Excel 2011 Mac
    Posts
    17

    Re: Script to have your form check the contents of a cell and reply different results

    The system it is going to be run on is actually windows, but I use a mac at home to make it. I will try it in work on windows and see what happens

  12. #12
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Script to have your form check the contents of a cell and reply different results

    In Mac you may not use Windows Common Controls (DTPicker) or RefEdit. If the titles in row 17 may be removed or placed above the data the code in #6 will work on Mac and PC.

  13. #13
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Script to have your form check the contents of a cell and reply different results

    You might try the example on your PC instead of Mac. For ease of use (and coding) I changed your Date txt box to a date picker control. With the DTPicker it will prevent your user from putting in a value that is NOT a date. Entering a value that is not a date will result in an error.

  14. #14
    Registered User
    Join Date
    12-02-2013
    Location
    London, UK
    MS-Off Ver
    Excel 2011 Mac
    Posts
    17

    Re: Script to have your form check the contents of a cell and reply different results

    Hi Solus and thanks for the update. I will steal my fathers windows laptop tomorrow and give it a whirl on there. I will get back to you with the results. Thank youuuuuuu.

  15. #15
    Registered User
    Join Date
    12-02-2013
    Location
    London, UK
    MS-Off Ver
    Excel 2011 Mac
    Posts
    17

    Re: Script to have your form check the contents of a cell and reply different results

    Hi ya. Its been a while, been very busy at work. Happy new year.

    I finally managed to get my fathers windows computer but it is still saying that it is not a file that is recognized and I don't know why?? Any ideas?

+ 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. I need an excel script that will check each cell content and copy stuff
    By caballar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2013, 02:38 AM
  2. Replies: 8
    Last Post: 05-14-2013, 01:11 PM
  3. Replies: 1
    Last Post: 04-07-2010, 02:28 PM
  4. Check cell contents
    By nabialekp in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-15-2006, 12:55 AM
  5. [SOLVED] Reply to outlook email from excel script
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-21-2006, 12:00 PM

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