Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Default Windows Profile without default Office user info Karen Excel Discussion (Misc queries) 0 November 12th 08 04:53 PM
Default ribbon to open by default when opening xls in browser Hank Excel Discussion (Misc queries) 0 April 10th 08 10:12 PM
Default Set up Gor_yee Excel Discussion (Misc queries) 6 January 8th 07 11:46 AM
default value hustla7 Excel Discussion (Misc queries) 8 August 19th 06 07:17 PM
IDE default Antonio Excel Discussion (Misc queries) 0 June 6th 06 06:14 PM


All times are GMT +1. The time now is 10:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"