ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Help with creating a function (https://www.excelbanter.com/excel-worksheet-functions/218815-help-creating-function.html)

Craig

Help with creating a function
 
Hi,

I need help with this function.

=IF(D2="text", "G2","0")

When I copy the formula to the cells below it changes the reference of the
logical test, which is great, but I also need it to change the reference cell
of the true result. So that when I copy it to the cell below it becomes:

=IF(D3="text", "G3","0")

Thanks,

Craig



JE McGimpsey

Help with creating a function
 
Are you trying to return the *value* that is in cel G3, G4, etc?

Then

=IF(D3="text", G3, 0)

If you're trying to return the text strings "G3", "G4", etc., and the
text string "0", then, assuming your formula is in row 3:

=IF(D3="text", "G" & ROW(), "0")

If it's in a different row, add or subtract a value to suit. For
instance, if the formula is in row 2:

=IF(D3="text", "G" & ROW()+1, "0")


In article ,
Craig wrote:

Hi,

I need help with this function.

=IF(D2="text", "G2","0")

When I copy the formula to the cells below it changes the reference of the
logical test, which is great, but I also need it to change the reference cell
of the true result. So that when I copy it to the cell below it becomes:

=IF(D3="text", "G3","0")

Thanks,

Craig


David Biddulph[_2_]

Help with creating a function
 
You haven't given a reference cell of the true result, you have given a text
string "G2".
If you wish G2 to be a cell reference, it doesn't have quotes around it. In
that case it will happily update as you copy to the row below.
Similarly, if you want the alternative result to be number zero, rather than
a text string, you don't want the quotes round that either.
--
David Biddulph

Craig wrote:
Hi,

I need help with this function.

=IF(D2="text", "G2","0")

When I copy the formula to the cells below it changes the reference
of the logical test, which is great, but I also need it to change the
reference cell of the true result. So that when I copy it to the
cell below it becomes:

=IF(D3="text", "G3","0")

Thanks,

Craig




Lars-Åke Aspelin[_2_]

Help with creating a function
 
On Mon, 2 Feb 2009 13:23:01 -0800, Craig
wrote:

Hi,

I need help with this function.

=IF(D2="text", "G2","0")

When I copy the formula to the cells below it changes the reference of the
logical test, which is great, but I also need it to change the reference cell
of the true result. So that when I copy it to the cell below it becomes:

=IF(D3="text", "G3","0")

Thanks,

Craig


Try this:

=IF(D2="text","G"&ROW(G2),"0")

Hope this helps / Lars-Åke

Craig

Help with creating a function
 
Thanks, that was very helpful. I removed the quotes around the true result
and removed the quotes in the false result and it updates the function
perfectly. I ended up with this:

=IF(D2="text", G2,"")

Craig

"David Biddulph" wrote:

You haven't given a reference cell of the true result, you have given a text
string "G2".
If you wish G2 to be a cell reference, it doesn't have quotes around it. In
that case it will happily update as you copy to the row below.
Similarly, if you want the alternative result to be number zero, rather than
a text string, you don't want the quotes round that either.
--
David Biddulph

Craig wrote:
Hi,

I need help with this function.

=IF(D2="text", "G2","0")

When I copy the formula to the cells below it changes the reference
of the logical test, which is great, but I also need it to change the
reference cell of the true result. So that when I copy it to the
cell below it becomes:

=IF(D3="text", "G3","0")

Thanks,

Craig






All times are GMT +1. The time now is 08:45 AM.

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