UserVal default value

B

Brad

For a UserVal prompt within VBA code, what additional lines of code would I
need to insert so that if I hit the enter key without providing a value, it
defaults to a predetermined value?

My thanks in advance for help on this matter.

Cheers! Brad
 
D

Dnereb

You could use the on_change event of the workbook to do this:


Code:
--------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'if the target contains multiple cells do nothing
If Target.Columns.Count > 1 Or Target.Rows.Count > 1 Then Exit Sub

'If the target is empty on changing it store a standard value
If Len(Cells(Target.Row, Target.Column) & "") = 0 Then
Cells(Target.Row, Target.Column) = "Standard Value"
End If
--------------------


It probably needs a bit of tinkering for your needs. but this VBA does
the BASIC if you place it in the workbook.
Quastions? mail me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top