How to prevent blank or missing entries in cells in Excel?
Supposing you are creating a table in range A1:B10 of a worksheet and need to prevent blank cell appearing in this table range, how to achieve it? This article introduces a method to automatically pop up prompt box if blank entry appearing in a certain table range while editing. Please follow the method step by step in the article.
- Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
- More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
- Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
- Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
- Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
- Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
- More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.
A1:B10 is the range where you need to create table inside, and A1, B1 contain the headers of the table as below screenshot shown. Please do as follows to prevent blank or missing entries appearing in range A2:B10 while creating the table.
1. In the worksheet which you won’t allow blank entries in certain range, right click the sheet tab, and then click View Code from the right-clicking menu.
2. In the Microsoft Visual Basic for Applications window, copy and paste the below VBA code into the Code window. See screenshot:
VBA code: Prevent blank or missing entries in a range of cells
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Count <> 1 Then Exit Sub Dim isect As Range On Error Resume Next Set isect = Application.Intersect(Target, Range("A2:B10")) If Not (isect Is Nothing) Then If Target.Column = 1 Then If Len(Target.Value) > 0 And Len(Target.Offset(-1, 0).Value) = 0 Then MsgBox "You cannot skip a row in column A2:B10", vbInformation, "Kutools for Excel" Target.ClearContents End If Else If (Len(Target.Value) > 0 And Len(Target.Offset(-1, 0).Value) = 0) Or (Len(Target.Value) > 0 And Len(Target.Offset(0, -1).Value) = 0) Then MsgBox "You cannot skip a row in column A2:B10", vbInformation, "Kutools for Excel" Target.ClearContents End If End If End If End Sub
Note: In the VBA code, A2:B10 is the range of cells which you don’t want to leave any empty cell inside. Please change the range as you need.
From now on, when you skipping blank cell and fill in the next cell in the specified range directly, you will get a Kutools for Excel dialog box as below screenshot shown.
- How to prevent data entry into specific cells of a worksheet in Excel?
- How to prevent selection of multiple worksheets in Excel?
- How to prevent a certain worksheet from being deleted in Excel?
- How to prevent specific cell contents from being deleted in Excel?