+ Reply to Thread
Results 1 to 3 of 3

Error check to see if cells are filled in

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    Error check to see if cells are filled in

    I have this MICRO that simply selects a cell

    Sub Step4()
        Range("A91").Select
    End Sub
    ... but I DO NOT want it to do that IF cells "D4" and/or "J4" and/or "G4 are blank.

    Rather return an error message saying:
    (If D4 is blank) "Please enter your name."
    (If J4 is blank) "Please enter the quantity of your order."
    (If G4 is blank) "Please enter a language."

    Thanks!

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Error check to see if cells are filled in

    nenadmail,

    One way...
    Sub Step4()
        Dim i As Long
        Dim strAddress As String
        For i = 1 To 3
            strAddress = Choose(i, "D4", "J4", "G4")
            If Len(Trim(Range(strAddress).Value)) = 0 Then
                Range(strAddress).Select
                MsgBox "Please enter " & Choose(i, "your name.", "the quantity of your order.", "a language.")
                Exit Sub
            End If
        Next i
        Range("A91").Select
    End Sub
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    Re: Error check to see if cells are filled in

    Cool. Thanks!

+ 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