Conditional Locking if Cells below are blank

KCrtz

New Member
Joined
Jan 24, 2020
Messages
2
Office Version
365
Platform
Windows
I was able to get the coding below to working using the logic in this link below; however, when I apply this to 30 lines of data I get so many message boxes you have to force excel to close to move on. How can I consolidate this code to only show one error message?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("G13:G41")) Is Nothing Then Exit Sub
If Range("G12") = "" Then
MsgBox ("Please completed blend in order")
Range("G12").Select
End If
If Intersect(Target, Range("G14:G41")) Is Nothing Then Exit Sub
If Range("G13") = "" Then
MsgBox ("Please completed blend in order")
Range("G13").Select
End If
If Intersect(Target, Range("G15:G41")) Is Nothing Then Exit Sub
If Range("G14") = "" Then
MsgBox ("Please completed blend in order")
Range("G14").Select
End If
If Intersect(Target, Range("G16:G41")) Is Nothing Then Exit Sub
If Range("G15") = "" Then
MsgBox ("Please completed blend in order")
Range("G15").Select
End If
End Sub

 

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Kamolga

Well-known Member
Joined
Jan 28, 2015
Messages
1,170
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("G13:G41")) Is Nothing Then Exit Sub
If ActiveCell.Offset(-1, 0) = "" Then
MsgBox ("Please completed blend in order")
Application.EnableEvents = False
ActiveCell.Offset(-1, 0).Select
Application.EnableEvents = True
End If
End Sub
 

KCrtz

New Member
Joined
Jan 24, 2020
Messages
2
Office Version
365
Platform
Windows
That worked! Thanks so much!!
 

Forum statistics

Threads
1,089,438
Messages
5,408,221
Members
403,191
Latest member
fmstation

This Week's Hot Topics

  • help please
    SORRY NOT ANY GOOD AT EXCEL SO HELP WOULD BE MUCH APPRECIATED this formula is in a sheet called ignore...
  • two formulas needed
    Hello, I'll try my best to explain this: First formula needed in Sheet1 cell A2: If Sheet1 cell B2 = Sheet2 cell B2 then return a 1. If not then...
  • Dynamic Counts
    Good afternoon, we are tidying up some data & the data seems to be growing quicker than we are tidying it up! What we confirm (by reviewing it...
  • Help Excel formula eliminate duplicate values and keep only 2 identical rows.
    as picture below column A has a duplicate value. but the values are not the same as the rule. sometimes 4 rows, sometimes 10 rows or 7 or 9...
  • Macro Compile Error Sub or Function not defined
    Hello, I am trying to run macros from a validation list, all macros have been created and run perfectly on there own but I'm getting a compile...
  • Last row combined with Current Region VBA
    I'm generally happy finding the last row of data through something like Lastrow = Cells(Rows.Count, "D").End(xlUp) but I don't always receive data...
Top