Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
If a cell does not contain a formula then...
Column D accepts "Y" or "N"....If "Y" is chosen then a formula is entered
into column A of the same row. If "N" is chosen, then the contents of the cell in column A are removed. A user can put his/her own entry into the cell in column A....is there a way that excel can recognize whether the cell contains a formula or a value....and if the cell does not contain a formula to change the cell in column D to "N"? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
If a cell does not contain a formula then...
Hello Matt, You need to use the SelectionChange event of the Worksheet to test th cell the user has selected. Each worksheet has it's own events so, i you plan to use this on multiple worksheets, you must include this cod on each one. Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim R As Long R = Target.Row If Target.Column = 1 Then If Target.HasFormula = True Then Cells(R, "D").Value = "Y" Else Cells(R, "D").Value = "N" End If End If End Sub Sincerely, Leith Ros -- Leith Ros ----------------------------------------------------------------------- Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846 View this thread: http://www.excelforum.com/showthread.php?threadid=49202 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
If a cell does not contain a formula then...
You probably want to change that to a Worksheet_Change Event. If you use
the selection change the user will select a cell in column A which contains a formula, the event will fire and a Y will be inserted into column D. The user then types a number over the formula in the selected cell and the Y stays in Column D as the selection hasn't changed. Private Sub Worksheet_Change(ByVal Target As Range) Dim R As Long If Target.Count = 1 Then R = Target.Row If Target.Column = 1 And Target.HasFormula = True Then Cells(R, "D").Value = "Y" Else Cells(R, "D").Value = "N" End If End If End Sub Hope this helps Rowan Leith Ross wrote: Hello Matt, You need to use the SelectionChange event of the Worksheet to test the cell the user has selected. Each worksheet has it's own events so, if you plan to use this on multiple worksheets, you must include this code on each one. Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim R As Long R = Target.Row If Target.Column = 1 Then If Target.HasFormula = True Then Cells(R, "D").Value = "Y" Else Cells(R, "D").Value = "N" End If End If End Sub Sincerely, Leith Ross |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can I make a blank cell in a formula cell with a range of cell | Excel Discussion (Misc queries) | |||
adding a formula in a cell but when cell = 0 cell is blank | Excel Worksheet Functions | |||
Cell Formula reference to cell Based On third Cell Content | Excel Discussion (Misc queries) | |||
Cell Formula reference to cell Based On third Cell Content | Excel Discussion (Misc queries) | |||
Question: Cell formula or macro to write result of one cell to another cell | Excel Programming |