Input or can't move to next cell

Bedford

Active Member
Joined
Feb 3, 2015
Messages
316
Office Version
  1. 365
Platform
  1. MacOS
This could be a formula for conditional formatting, building a form that some cells are required to have an input before advancing to the next that requires input. Is it possible to prevent the user from moving to the next cell if the previous cell requiring input is left blank? Example, cell AD1 has a list, before the user can move to the next cell AD2 they must complete entry from the list in AD1.
Help.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I'm not sure it works on Mac Office, but try these 2 options:
OPTION 1
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Address = "$AD$2" And Range("AD1") = "" Then
    Application.EnableEvents = False
        Range("AD1").Activate
    Application.EnableEvents = True
End If

End Sub

This is an Event Procedure, you need to put it in the code module of the sheet, say sheet1. This is how:
Copy the code > open sheet1 > right click sheet1 tab > select View Code > paste the code.

OR

OPTION 2

Create data validation on cell AD2 then use this formula:
Rich (BB code):
=$AD$1<>""
and uncheck "Ignore blank".
You still can select AD2 but you can type anything in it.
If you want you can add specific message in Error Alert > Error Message, like "Cell AD1 must not be empty"
 
Upvote 0
Edit:
Sorry, I meant:
...but you can't type anything in it.
 
Upvote 0
Ya, I caught that. I'm going to give it a try, will let you know my findings. Thank you.
Edit:
Sorry, I meant:
...but you can't type anything in it.
So it seems to work in data validation, one thing I noticed, if someone wants to cheat the process, they can input in AD1, then input in AD2, then go back to AD1 and delete the input and the input in AD2 remains intact even though AD1 is now empty.
 
Upvote 0
if someone wants to cheat the process, they can input in AD1, then input in AD2, then go back to AD1 and delete the input and the input in AD2 remains intact even though AD1 is now empty.

You can try OPTION 3 (without data validation) :
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$AD$2" And Range("AD1") = "" Then
    Application.EnableEvents = False
        Target = ""
        Range("AD1").Activate
        MsgBox "Cell AD1 must not be empty"
    Application.EnableEvents = True
ElseIf Target.Address = "$AD$1" Then
    Application.EnableEvents = False
        Range("AD2") = ""
    Application.EnableEvents = True
End If

End Sub
if AD1 changes then AD2 will be blank.
 
Upvote 0
Solution
You can try OPTION 3 (without data validation) :
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$AD$2" And Range("AD1") = "" Then
    Application.EnableEvents = False
        Target = ""
        Range("AD1").Activate
        MsgBox "Cell AD1 must not be empty"
    Application.EnableEvents = True
ElseIf Target.Address = "$AD$1" Then
    Application.EnableEvents = False
        Range("AD2") = ""
    Application.EnableEvents = True
End If

End Sub
if AD1 changes then AD2 will be blank.
Akuini, sadly I suffer from 2 handicaps, the first being a mac user, and the second, a complete ignorance of VBA and code. My project is formula based as I'm needing it to run on iPads which can't work with VBA it seems. Thank you for your effort regardless.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top