Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Nan Nan is offline
external usenet poster
 
Posts: 23
Default Can you put a formula on a field that requires user input?

Here is the scenario that I need help on:
Cell_1 is a cell that doesn't contain any formulas or conditions.
Checkbox_A is a checkbox from the form tool.

If Checkbox_A is 'FALSE'(not checked), I want Cell_1 to change/default to
the number 0. If Checkbox_A is 'TRUE', I want the user to still be able to
enter a number into Cell_1, let's say 10,000. Normally, I would just put an
'if statement' on Cell_1 but since I also am expecting the user to input data
in this cell, it will overwrite the formula. Am I overlooking something
simple here? Is there VB code that would take care of this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Can you put a formula on a field that requires user input?

Hi
In a code module copy/paste the following sub which sets the cell A1 to 0
when the user will check the checkbox:
'------------------------------------------------
Sub SetCell1()
Dim cell As Range
Set cell = ActiveSheet.Range("A1")
If ActiveSheet.CheckBoxes(1).Value = 1 Then ' when Checked
'(could use checboxes("name") too)
cell.Value = 0
End If
End Sub
'-----------------------------------------------
Now, right-click on the checkbox in the sheet, and from the pop-up menu,
choose Assign Macro. In the Assign Macro Dialog, select the SetCell1 sub.
Now the SetCell1 is rtun everytime the checkbox is clicked.
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Nan" wrote:

Here is the scenario that I need help on:
Cell_1 is a cell that doesn't contain any formulas or conditions.
Checkbox_A is a checkbox from the form tool.

If Checkbox_A is 'FALSE'(not checked), I want Cell_1 to change/default to
the number 0. If Checkbox_A is 'TRUE', I want the user to still be able to
enter a number into Cell_1, let's say 10,000. Normally, I would just put an
'if statement' on Cell_1 but since I also am expecting the user to input data
in this cell, it will overwrite the formula. Am I overlooking something
simple here? Is there VB code that would take care of this?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Can you put a formula on a field that requires user input?

You can assign a macro to the checkbox to perform those actions

Right click on the checkbox and select assign macro, then select your macro
from the dialog - a macro such as:

Sub Checkbox_A_Click()
Dim sname as String
Dim rng as Range
Dim cbox as CheckBox
sname = application.Caller
set cbox = Activesheet.CheckBoxes(sName)
set rng = Range("Cell_1")
if cbox.Value = xlOn then
if isempty(rng) or rng.value = 0 then
rng.clearcontents
else
rng.value = 0
end if
End if
End Sub

--
Regards,
Tom Ogilvy


"Nan" wrote in message
...
Here is the scenario that I need help on:
Cell_1 is a cell that doesn't contain any formulas or conditions.
Checkbox_A is a checkbox from the form tool.

If Checkbox_A is 'FALSE'(not checked), I want Cell_1 to change/default to
the number 0. If Checkbox_A is 'TRUE', I want the user to still be able

to
enter a number into Cell_1, let's say 10,000. Normally, I would just put

an
'if statement' on Cell_1 but since I also am expecting the user to input

data
in this cell, it will overwrite the formula. Am I overlooking something
simple here? Is there VB code that would take care of this?



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
How get user input that can then be used in formula, as criteria? jcoelho Excel Worksheet Functions 2 July 1st 08 04:58 AM
Can I request user in input variable value within formula? R Nelson Excel Worksheet Functions 11 June 3rd 08 01:29 PM
How can I calculate user input from a combo box into a formula? Quizboy Excel Worksheet Functions 0 November 16th 05 06:11 PM
User input formula variable Petr Excel Programming 3 December 9th 04 01:59 PM
CODE to select range based on User Input or Value of Input Field Sandi Gauthier Excel Programming 4 December 8th 03 03:22 PM


All times are GMT +1. The time now is 07:19 AM.

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"