ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   using IF function to copy, but leave populated cell alone (https://www.excelbanter.com/excel-worksheet-functions/88247-using-if-function-copy-but-leave-populated-cell-alone.html)

[email protected]

using IF function to copy, but leave populated cell alone
 
I am using the IF function to look for a particular word and copy it to
another cell.

H2: =IF(A2="Example Text",A2, "")

The problem is that if the word "Example Text" is not found it deletes
anything in the target cell or puts FALSE into the target cell (if I
take out the "").

How can I preserve the text in the target cell if "Example Text" is not
there?

any help would be greatly appreciated!!


davemorrison

using IF function to copy, but leave populated cell alone
 
you are asking
if A2 = Example Text then Example Text
if not then Blank

is this what you want??

maybe
=if(A2="Example Text","",A2)


[email protected]

using IF function to copy, but leave populated cell alone
 
Not exactly (thanks for the try)... that puts a blank where some test
was that I want to keep.

It would be more like =IF(A1="yes","yes", DO NOTHING)

where do nothing means leave that cell alone!

Befo
A B
1 example text (blank)
2 BlahBla goodstuff
3 example text (blank)

After:
A B
1 example text example text
2 BlahBla goodstuff
3 example text example text


JMB

using IF function to copy, but leave populated cell alone
 
Whatever other data you want in the cell if the criteria is not met should be
your third parameter. Or, your third parameter could be another if statement
to test for some other data, and if that is not found, return a "". Unless
they are nested or concatenated, two functions or pieces of data cannot
occupy the same cell.

IF(A1="yes",A1,other data)

IF (A1="yes",A1,IF(test for other data, other data, ""))


" wrote:

Not exactly (thanks for the try)... that puts a blank where some test
was that I want to keep.

It would be more like =IF(A1="yes","yes", DO NOTHING)

where do nothing means leave that cell alone!

Befo
A B
1 example text (blank)
2 BlahBla goodstuff
3 example text (blank)

After:
A B
1 example text example text
2 BlahBla goodstuff
3 example text example text



JMB

using IF function to copy, but leave populated cell alone
 
One other thing, you could enter the first IF statement I suggested in a
third column, then copy this third column, click Edit/Paste Special/Values
over your original data in column B.

Just be sure to back up before trying anything new.


" wrote:

Not exactly (thanks for the try)... that puts a blank where some test
was that I want to keep.

It would be more like =IF(A1="yes","yes", DO NOTHING)

where do nothing means leave that cell alone!

Befo
A B
1 example text (blank)
2 BlahBla goodstuff
3 example text (blank)

After:
A B
1 example text example text
2 BlahBla goodstuff
3 example text example text



[email protected]

using IF function to copy, but leave populated cell alone
 
Here is what I ended up using in VBA

Dim TheCell As Range

For C = 1 To 100
Set TheCell = Cells(C, 2)
If IsEmpty(TheCell.Value) Then
TheCell.Value = TheCell.Offset(0, -1).Value
End If
Next C
End Sub

use a second loop if you want to continue to add the text to addition
cells


JMB wrote:
One other thing, you could enter the first IF statement I suggested in a
third column, then copy this third column, click Edit/Paste Special/Values
over your original data in column B.

Just be sure to back up before trying anything new.


" wrote:

Not exactly (thanks for the try)... that puts a blank where some test
was that I want to keep.

It would be more like =IF(A1="yes","yes", DO NOTHING)

where do nothing means leave that cell alone!

Befo
A B
1 example text (blank)
2 BlahBla goodstuff
3 example text (blank)

After:
A B
1 example text example text
2 BlahBla goodstuff
3 example text example text





All times are GMT +1. The time now is 01:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com