+ Reply to Thread
Results 1 to 10 of 10

Help modifying code to check for text in a range prior to email sheet.

  1. #1
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Help modifying code to check for text in a range prior to email sheet.

    Hello, I am using the code below tied to a button on the worksheet to email a sheet and would like it to check that there has been text entered intothe cells below prior to emailing the sheet. If the cells have no text entered i would like a message box to pop up stating that all fields need to be completed.

    Range of cells:
    H6,A9,F9,A12,F12,A16,A23,A26,C28,D30,D32,D34,A37,D39,F36,F28


    Email code I am using:

    Please Login or Register  to view this content.
    I tried to adapt this code, but it is far to advanced for me to wrap my head around. If it could be made to check the range of cells I have provided prior to the execution of the code above that would be fantastic.

    Please Login or Register  to view this content.
    Thank you for any help you may be able to provide!

    This is posted at VBAexpress.com as well.

    Clayton
    Last edited by dcgrove; 07-09-2009 at 06:16 PM.

  2. #2
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    using 16 cells in "If Range("XX","XXY)" is failing

    hello, I am trying to use 16 cells below and it is failing. It does not fail when I only have one cell. Is there a limit to how many cells you can put in there?

    Please Login or Register  to view this content.
    What I am trying to accomplish is that if any of these cells are empty to kill the whole macro. This code is part of a larger one I use. I could write an if statement for each cell, but I am trying to simplify and shorten the process (and learn something new)!
    Thanks!

    Clayton

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: using 16 cells in "If Range("XX","XXY)" is failing

    [removed - garbage! - apologies]
    Last edited by DonkeyOte; 07-09-2009 at 06:02 PM.

  4. #4
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Re: using 16 cells in "If Range("XX","XXY)" is failing

    Donkeyote, that code fails to an error message stating "compile error: wrong number of arguments or invalid property assignment."

    Any ideas? My original code failed to same message.

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: using 16 cells in "If Range("XX","XXY)" is failing

    What is the content of the cells when populated - text / number / mix ?

    I removed my last post as it was nonsense - aparat from the syntax error COUNTBLANK does not accept non-contiguous ranges... COUNTA / COUNT do so you could potential use that rather than:

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Re: using 16 cells in "If Range("XX","XXY)" is failing

    Some cells will be text, some numbers and some both.

  7. #7
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: using 16 cells in "If Range("XX","XXY)" is failing

    How about:
    Please Login or Register  to view this content.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Help modifying code to check for text in a range prior to email sheet.

    Or ...
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Help modifying code to check for text in a range prior to email sheet.

    I merged your two threads - please try to keep to one thread going forward.

    Re: Paul's COUNTA approach - this will work unless the cells are populated with formulae Nulls - let us know.

  10. #10
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Re: Help modifying code to check for text in a range prior to email sheet.

    Thanks everyone for the help and thanks donkeyote for merging the threads. Pauls code solved my problems. You guys rock!


    clayton

+ 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