ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Generic function applied to column? (https://www.excelbanter.com/excel-programming/355477-generic-function-applied-column.html)

[email protected]

Generic function applied to column?
 
I'd like to know if there is a way to apply a function to a column that
will "execute" on each cell on that column. I have 3 columns where
columns A and B contain dates and I want the third column's cells to
display some text based upon the dates in it's respective cells on
columns A and B. So, I am trying to avoid going to every cell in
column C and entering a function such as: IF(A1 = B1, "Dates are
equal", "Dates are not equal"). In this scenario, I'd have to write a
similar function for rows 1, 2, 3, 4, etc. I'd like to write a
function such as (in pseudocode): IF(CurrentRowCell - 1 =
CurrentRowCell - 2, "Dates are equal", "Dates are not equal").

My goal is to write this generic function once and somehow make it
execute on column C. That way when any dates are changed on columns A
or B then the respective cell on column C would be automatically
updated. Is this possible?

I suppose another way to do this is to create a macro that I would have
to run (manually or based upon some event) that could iterate through
all the cells in columns A and B and update the respective cell in
column C.

Any help would be much appreciated.


Toppers

Generic function applied to column?
 
Look at Worksheet event functions:

http://www.mvps.org/dmcritchie/excel/event.htm

E.g. Worksheet_Change could check if columns A and/or B had changed and then
test/change message in C

HTH

" wrote:

I'd like to know if there is a way to apply a function to a column that
will "execute" on each cell on that column. I have 3 columns where
columns A and B contain dates and I want the third column's cells to
display some text based upon the dates in it's respective cells on
columns A and B. So, I am trying to avoid going to every cell in
column C and entering a function such as: IF(A1 = B1, "Dates are
equal", "Dates are not equal"). In this scenario, I'd have to write a
similar function for rows 1, 2, 3, 4, etc. I'd like to write a
function such as (in pseudocode): IF(CurrentRowCell - 1 =
CurrentRowCell - 2, "Dates are equal", "Dates are not equal").

My goal is to write this generic function once and somehow make it
execute on column C. That way when any dates are changed on columns A
or B then the respective cell on column C would be automatically
updated. Is this possible?

I suppose another way to do this is to create a macro that I would have
to run (manually or based upon some event) that could iterate through
all the cells in columns A and B and update the respective cell in
column C.

Any help would be much appreciated.



[email protected]

Generic function applied to column?
 
What Topper writes is probably true, but if I understand what you want
to do it's really much easier than you think. Just make the formula one
time in row 1 and then copy and paste it to your other rows. Excel will
take care of adjusting the row references for you.

If you're putting the formula in Column C, it will be =IF(A1=B1,"Text
you want if TRUE","What you want if FALSE")



All times are GMT +1. The time now is 05:26 PM.

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