Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default Default Value?

I created a bunch of Validation lists that give me the final "DEFAULT VALUE"
lets say it's in B2 how can I set it so that when you tab through a cell
without entering a value it defaults to the value in B2?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Default Value?

You could insert a SelectionChange subroutine in the sheet object in VBA.

If, for example, cell E2 has data validation, you could insert the following
code:

Option Explicit
Dim strVal As String
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("E2").Value = "" Then
strVal = Range("E2").Validation.Formula1
strVal = Mid(strVal, 2, InStr(1, strVal, ":") - 2)
Range("E2").Value = Range(strVal).Value
End If
End Sub

Any time a cell is selected in the sheet and cell E2 is blank, it will look
for the first cell specified in the data validation list and insert its value
in E2 as default. Even if the cell value is deleted, it will be replaced
with the default value.

This code will work with any cell with data validation and will correctly
get the first cell in the validation list specified for that cell (looking in
Formula1).

Glenn Ray
MOS Expert


"HotRod" wrote:

I created a bunch of Validation lists that give me the final "DEFAULT VALUE"
lets say it's in B2 how can I set it so that when you tab through a cell
without entering a value it defaults to the value in B2?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default Default Value?

I will give it a try THANKS.


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 for Look Up denimead Setting up and Configuration of Excel 0 October 22nd 07 04:17 PM
Default Set up Gor_yee Excel Discussion (Misc queries) 6 January 8th 07 11:46 AM
IDE default Antonio Excel Discussion (Misc queries) 0 June 6th 06 06:14 PM


All times are GMT +1. The time now is 12:33 AM.

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

About Us

"It's about Microsoft Excel"