Microsoft Office Tutorials and References
In Depth Information
Working with Ranges
End If
Msg = “Your previous entry was INVALID.”
Msg = Msg & vbNewLine
Msg = Msg & “Enter a value between “ & MinVal & “ and “ & MaxVal
Loop
ActiveSheet.Range(“A1”).Value = UserEntry
End Sub
As you can see in Figure 11-4, the code also changes the message displayed if the user makes an
invalid entry.
The three GetValue procedures are available on the companion CD-ROM. The filename
is inputbox demo.xlsm .
Figure 11-4: Validate a user’s entry with the VBA InputBox function.
Entering a value in the next empty cell
A common requirement is to enter a value into the next empty cell in a column or row. The
following example prompts the user for a name and a value and then enters the data into the next
empty row (see Figure 11-5).
Figure 11-5: A macro for inserting data into the next empty row in a worksheet.
 
Search JabSto ::




Custom Search