Make sure users enter data into all cells

Amy DeLuca

New Member
Joined
Oct 18, 2002
Messages
39
I need to force the user to enter data in every cell before clicking the "Next" button I have put in. Is this possible without using a VB form?
This message was edited by Amy DeLuca on 2002-10-19 14:22
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi Amy,

Yes, this is easy to do. Here is an example. This code added to your button's Click event will check to make sure all the cells in E1:E6, B1:B6, and G4 contain data. It selects the first empty cell it finds and displays an error message. While this code just checks to make sure there are no empty cells, it would also be easy to go further and do checking on the inputs to make sure they are valid entries.

Private Sub NextButton_Click()
'The user must enter data into all the defined cells before
'clicking this button.
Dim Cel As Range
For Each Cel In [b1:b6, e1:e6, h4]
If IsEmpty(Cel) Then
Cel.Select
MsgBox "Missing data", vbExclamation, "Can't proceed without all data"
Exit Sub
End If
Next Cel

' Now put your Next Click code here

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,787
Messages
6,126,900
Members
449,348
Latest member
Rdeane

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