+ Reply to Thread
Results 1 to 5 of 5

If any cell in Selection is Empty give Error MsgBox

  1. #1
    Registered User
    Join Date
    01-03-2020
    Location
    Luxembourg
    MS-Off Ver
    2013
    Posts
    4

    If any cell in Selection is Empty give Error MsgBox

    Hi all,
    I´ve got a problem. I´m trying to write an macro like:

    Sub XISN2()
    Dim cell As Range
    Dim bIsNumeric As Boolean

    bIsNumeric = True
    For Each cell In Range("A2:A100000")
    If IsNumeric(cell) = False Then

    bIsNumeric = False
    Exit For
    End If
    Next cell

    If bIsNumeric = True Then

    MsgBox "Opening Date OK - Data Import Successful"
    Else
    MsgBox "ERROR in Opening Date - Check Data Import"
    End If
    End Sub

    But instead of looking for numeric values. I want the macro to check the dynamic range of column A if there is any empty/blank cell and
    then return an error/valid Message to the user.
    Thanks in advance.

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,444

    Re: If any cell in Selection is Empty give Error MsgBox

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    01-03-2020
    Location
    Luxembourg
    MS-Off Ver
    2013
    Posts
    4

    Re: If any cell in Selection is Empty give Error MsgBox

    Sub XISE()
    Dim myCellRange As Range

    Set myCellRange = ThisWorkbook.Worksheets("Combined").Range("A1:A80000")

    If WorksheetFunction.CountA(myCellRange) < myCellRange.Count Then
    MsgBox "Quality Check II - ERROR in Opening Date - Check Data Import"
    Else
    MsgBox "Quality Check II - Opening Date OK - Data Import Successful"
    End If
    End Sub

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,356

    Re: If any cell in Selection is Empty give Error MsgBox

    Please use Code Tags when posting code.

    You wanted to check dynamic Range.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  5. #5
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2504
    Posts
    13,631

    Re: If any cell in Selection is Empty give Error MsgBox

    @miartlopa

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)

+ 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] Msgbox when Cell is Empty
    By Andrew.Trevayne in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-15-2017, 03:19 AM
  2. Replies: 3
    Last Post: 07-21-2015, 09:15 AM
  3. Replies: 1
    Last Post: 04-01-2014, 08:10 AM
  4. If Runtime error Shows up then Give a Msgbox (for userform)
    By ohboyherewegoagain in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-17-2014, 09:20 AM
  5. [SOLVED] Selection of the cell after msgbox
    By UsmanBPD in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-29-2012, 06:49 AM
  6. Error Setting Selection.Formula in an Empty ListColumn
    By yourang in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-30-2010, 11:16 AM
  7. Msgbox - when cell is empty
    By KA_Analyst in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-15-2007, 04:36 PM

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