ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UserVal default value (https://www.excelbanter.com/excel-programming/347172-userval-default-value.html)

Brad

UserVal default value
 
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



Dnereb[_34_]

UserVal default value
 

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.


--
Dnereb


------------------------------------------------------------------------
Dnereb's Profile: http://www.excelforum.com/member.php...o&userid=26182
View this thread: http://www.excelforum.com/showthread...hreadid=490215


Tom Ogilvy

UserVal default value
 
res = application.Inputbox("enter value","Value Entry","My Default Value")

--
Regards,
Tom Ogilvy


"Brad" wrote in message
...
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






All times are GMT +1. The time now is 11:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com