LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Setting Default Values in Range When User Enters Blank Value

I have a Cell in my workbook named "Test" Lets say I have VBA module that
involves that cell to do some calculations..as an example Increment that cell
by 1.

Sub Increment()
Test = Test + 1
End Sub

When a user doesn't know what value to input into that cell, I want to allow
him to input a blank in that cell to signal my software to create a default
responce based on other cell values. My first task is to trap the user
inputing a "" value into the cell of interest ("Test"). I did this by using
the Worksheet_Change event:

Sub Worksheet_Change(ByVal Target As Range)
If Target.Value2 = "" Then
On Error Resume Next
m_Target.Name.Name = False 'm_Test in this case sets flag for
properties below (does not work)
End If
End Sub

Elsewhere in the workbook I have the following code to interface with my VBA
code:

Dim m_Test As Boolean
Public Property Get Test() As Double
If m_Test = False Then
Test = 12 'Default value for this cell
Else
Test = Range("Test").Value2
End If
End Property
Public Property Let Test(Value As Double)
If Value = vbNull Then
m_Test = False
Range("Test").Value2 = 12
Else
m_Test = True
Range("Test").Value2 = Value
End If
End Property

Does anybody out there have a better approach or know how to make this one
work?

 
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
Setting default values in a drop down list in excel? Dave Excel Discussion (Misc queries) 2 May 18th 06 07:33 AM
Setting a default sort for a range cHris New Users to Excel 2 April 26th 06 09:32 AM
Copy cell properties from master when user enters a new line. Hippy Excel Programming 1 January 13th 06 11:23 PM
Setting up a Custom type, User-defined, Default Chart Kurt Charts and Charting in Excel 0 December 22nd 05 07:43 PM
User enters data in popup box - its entered into desired cell ian123[_30_] Excel Programming 1 December 28th 03 03:16 PM


All times are GMT +1. The time now is 11:58 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"