View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Mo2 Mo2 is offline
external usenet poster
 
Posts: 34
Default need macro to edit formula...

hey.. umm...something's not right..
its still the same. As i copy the formula down,

the "D25" changes to "D26", "D26", etc, as it should..
but the "+20" stays as "+20" -- when it should change to "+21", "+22", etc
, as its copied down..

whats wrong?


"Vergel Adriano" wrote:

Hi,

Try the second formula that I gave.

=IF(D25=0,0,IF(INDIRECT("D" & ROW()+20+$A$1)=0,0,INDIRECT("B" &
ROW()+20+$A$1)))



--
Hope that helps.

Vergel Adriano


"Mo2" wrote:

problem!

when the formula was: =IF(D25=0,0,IF(D45=0,0,B45))
and when i copied it down,
it became =IF(D26=0,0,IF(D46=0,0,B46))
thats how i wanted it..

but with this formula:
=IF(D25=0,0,IF(INDIRECT("D" & 45+$A$1)=0,0,INDIRECT("B" & 45+$A$1)))

copied down, only the "D25" would will update to "D26" and so on.
but the "45" will remain a 45 when copy the formula down..
what to do?

i have hundreds of cells.. it will take me forever to change the 45 to 46,
47, 48, etc (for every new row i copy it down to)

is there another way?



"Mo2" wrote:

nice! thank you it works

i'll let you know if i have any more problems:)

thanks again




"Vergel Adriano" wrote:

If I understand it correctly, I think this should work (or at least give you
some idea to do what you're trying to accomplish). Try putting this formula
in G25:

=IF(D25=0,0,IF(INDIRECT("D" & 45+$A$1)=0,0,INDIRECT("B" & 45+$A$1)))

then copy down as needed. The row number of the cell references will always
be 45 plus whatever number is in A1. If you need the row number to increment
as you copy down, try it this way:

=IF(D25=0,0,IF(INDIRECT("D" & ROW()+20+$A$1)=0,0,INDIRECT("B" &
ROW()+20+$A$1)))

then copy down as needed.

--
Hope that helps.

Vergel Adriano


"Mo2" wrote:

this is difficult to explain, but here goes nothing...

here's my sample formula, in Cell G25:
=IF(D25=0,0,IF(D45=0,0,B45))

This is what i want the macro to do:
Step1: read the number in cell A1. (lets say i type "2" in there)

Step2: Add "2" to every cell reference in G25's formula, except the
reference that refers to the current cell's row (in this case, row 25).

I.E. this would change G25's formula from: =IF(D25=0,0,IF(D47=0,0,B47))
to:
=IF(D25=0,0,IF(D47=0,0,B47))

STEP3: copy the new formula down for 20 rows.

I need this same thing to happen, if i type a number in A2
(except this time, it would be looking at the formula in I25
and following the same steps.
I25's formula is : =IF(D25=0,0,IF(D44=0,0,B44))


can anybody help me please?
if this can be done through some sort of pop up (which startup as soon as i
open the worksheet), instead of typing a number in a cell, even better. but
either way will work for me:)

thanks in advance