ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing (https://www.excelbanter.com/excel-discussion-misc-queries/236473-code-copy-formulae-one-cell-all-cell-rangewith-specific-cell-columnnumber-changing.html)

Yuvraj

Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing
 
Hi All,

I have a button whose job is to reset the value of a given range of
cells and then fill it with a formulae.

I know that if a range say value.001 is from B5 to B11 I can just
write the code:

Dim rng as Range

Set rng=Thisworkbook.Names("value.001").ReferstoRange
rng.Cells(1,1).Formulae="IF(Sheet1!AR66=0,0,($M$2* $B5)*Sheet1!AR66)"
rng.FillDown

but problem here is that value.001 is from B5 to Z11

and I need to copy these formulae across and down also.

Across the formulaes keeps changing like for C5 the formulae is =IF
(Sheet1!AS66=0,0,($M$2*$B5)*Sheet1!AS66)"

and down like for B6 it is

=IF(Sheet1!AR67=0,0,($M$2*$B6)*Sheet1!AR67)

Now rng.Filldown would have increment the numbers of AR67 to AR68 and
so on.

The excel has function of fillright, filldown and fillup. But if I
want a function or code that can do what i want across and down for
all the cells in a range.

Please guide,

Regards,

Yuvraj



All times are GMT +1. The time now is 09:17 PM.

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