Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 516
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default 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
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 can I make a blank cell in a formula cell with a range of cell Vi Excel Discussion (Misc queries) 5 June 21st 07 02:46 PM
adding a formula in a cell but when cell = 0 cell is blank Mike T Excel Worksheet Functions 5 May 31st 05 01:08 AM
Cell Formula reference to cell Based On third Cell Content Gabriel Excel Discussion (Misc queries) 1 February 11th 05 06:36 AM
Cell Formula reference to cell Based On third Cell Content Gabriel Excel Discussion (Misc queries) 0 February 11th 05 05:35 AM
Question: Cell formula or macro to write result of one cell to another cell Frederik Romanov Excel Programming 1 July 8th 03 03:03 PM


All times are GMT +1. The time now is 06:44 PM.

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"