+ Reply to Thread
Results 1 to 7 of 7

Macro to show a message when some cells in between before the last cell are empty

Hybrid View

  1. #1
    Registered User
    Join Date
    11-22-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    23

    Macro to show a message when some cells in between before the last cell are empty

    Hi All,

    I have a spreadsheet which has multiple rows and columns. Now I want to throw one single error message for all blank cells before the last cell with value. Below is a sample table:
    sun mon
    tue wed
    thur
    fri sat

    Currently I have the the below macro which shows popup message for every blank cell before last cell:
    For count3 = 1 To LastCol
            For RowCount = 8 To ws.Cells(Rows.Count, count3).End(xlUp).Row
           
            If Cells(RowCount, count3) = "" Then
                MsgBox ("Please give inputs in sequentially. Cells cannot be empty in between.")
            End If
            
           Next
        Next
    Can any one please help me with these?
    Last edited by vlady; 11-23-2012 at 03:45 AM. Reason: code tags

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Macro to show a message when some cells in between before the last cell are empty

    Can you please explain the below line

    before the last cell with value


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    11-22-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Macro to show a message when some cells in between before the last cell are empty

    Quote Originally Posted by :) Sixthsense :) View Post
    Can you please explain the below line
    In the table provided in the question you can see three cells are blank in between before the last cell with value, i.e. "fri" in column 1 and two cells are blank before "thur" . So I want to show a single message for all those blank cells.

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Macro to show a message when some cells in between before the last cell are empty

    Ok understood... What would be the expected Message box text you would like to get?

  5. #5
    Registered User
    Join Date
    11-22-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Macro to show a message when some cells in between before the last cell are empty

    Hey thnx for replying! the below text should be displayed:

    "Please give inputs in sequentially. Cells cannot be empty in between."

    Can you please give a code to accomplish this?

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Macro to show a message when some cells in between before the last cell are empty

    Sub CheckPoint()
    Dim EndCl As Integer, i As Integer, StRw As Byte
    Dim EndRw As Long, x As Long, CnT As Long
    Dim myMsG As String, myRng As Range
    
    EndCl = Cells(1, Columns.Count).End(xlToLeft).Column
    
    For i = 1 To EndCl
        StRw = 8
        EndRw = Cells(Rows.Count, i).End(xlUp).Row
        Set myRng = Range(Cells(StRw, i), Cells(EndRw, i))
        myMsG = "Please give inputs in sequentially. Cells cannot be empty in between."
        CnT = WorksheetFunction.CountA(myRng)
        
        If CnT <> myRng.Rows.Count And CnT <> 0 Then
            myMsG = myMsG & " Blanks Found In Column " & i
            MsgBox myMsG, vbInformation, "Blanks Found"
            myMsG = ""
        End If
    Next i
    
    End Sub

  7. #7
    Registered User
    Join Date
    11-22-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Macro to show a message when some cells in between before the last cell are empty

    Thanks a lot!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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