Automatically entering specific text.

  • Thread starter Thread starter atom
  • Start date Start date
A

atom

I want to enter text into one cell automatically, if conditions in
another cell are met.

Example:
If A2>0, then B2 should contain "x".

Is this possible?

thanks.
 
Wow. I know that was pretty simple, but I've been looking through thick
Excel formula books for days and couldn't find it! That's two questions
you've answered in minutes.

Thanks again.
 
In cell B2, enter the following:

=IF(A2>0,"X","")

The last argument, the empty string, causes the cell to be blank rather than
displaying zero.
--
HTH -

-Frank Isaacs
Dolphin Technology Corp.
http://vbapro.com
 
One other issue...

If A2 contains a number, I want B2 to contain "x" OR if B2 contains
a number, I want A2 to contain an "x". (The idea is, if one cell has
data the other should not have data.) Is there a way to do this without
a circular reference?
 
You could use an event macro:

Put this in the worksheet code module (right-click on the worksheet
tab, choose View Code, paste the code in the window that opens,
then click the XL icon on the toolbar to return to XL):

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("A2:B2")) Is Nothing Then
Application.EnableEvents = False
If Target(1).Address(0, 0) = "A2" Then
If IsNumeric(Range("A2").Value) Then _
Range("B2").Value = "x"
Else
If IsNumeric(Range("B2").Value) Then _
Range("A2").Value = "x"
End If
Application.EnableEvents = True
End If
End Sub
 
That works! Is there a way to make that work for a range of cells (A2:B2,
A3:B3, A4:B4, etc.), and is there a way to have the "x" only if the other
cell is NOT blank (i.e. If one cell is blank the other is, too. If one cell
has a number the other has "x").

Thanks again for taking the time to help me.
 
Back
Top