Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Programmatically increase the row # in a formula

Hello
This is a really silly questions but here it goes.
I have a sheet where in a cell I have this formula:
=IF(AND($C30,$A3=""),"",0)
It works fine and does what I want. However, programmatically, I place the
formula in the next cell down from it (just like the copy handle dragging
down 1 row).

This is what the macro recorder gives me:
Selection.AutoFill Destination:=Range("D3:D4"), Type:=xlFillDefault
Range("D3:D4").Select

Which makes sense, but I cannot hard code the Cell addresses (except in the
first on which is already in the cell).

Programmatically, how can I increase the row number by 1?

I tried this ** LOL ** but of course it did not work: ======= what a mess

Sheets("Sheet3").Range("D65536").End(xlUp).Offset( 1, 0).Formula =
"=IF(AND($C" & Rows(Sheets("Sheet3").Range("D65536").End(xlUp).Of fset(1, 0))
+ 1 & "0,$A" & Rows(Sheets("Sheet3").Range("D65536").End(xlUp).Of fset(1,
0)) + 1 & "=""),"""",0)"

Any suggestions?

Thank you so much
Terry V



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Programmatically increase the row # in a formula

Terry,

Try this

Selection.AutoFill Destination:=Selection.Resize(2, 1), Type:=xlFillDefault

The 2 is the number of rows to copy the formula to, 1 is the number of
columns. Adjust to suit

--

HTH

RP

"Terry V" wrote in message
...
Hello
This is a really silly questions but here it goes.
I have a sheet where in a cell I have this formula:
=IF(AND($C30,$A3=""),"",0)
It works fine and does what I want. However, programmatically, I place

the
formula in the next cell down from it (just like the copy handle dragging
down 1 row).

This is what the macro recorder gives me:
Selection.AutoFill Destination:=Range("D3:D4"), Type:=xlFillDefault
Range("D3:D4").Select

Which makes sense, but I cannot hard code the Cell addresses (except in

the
first on which is already in the cell).

Programmatically, how can I increase the row number by 1?

I tried this ** LOL ** but of course it did not work: ======= what a

mess

Sheets("Sheet3").Range("D65536").End(xlUp).Offset( 1, 0).Formula =
"=IF(AND($C" & Rows(Sheets("Sheet3").Range("D65536").End(xlUp).Of fset(1,

0))
+ 1 & "0,$A" & Rows(Sheets("Sheet3").Range("D65536").End(xlUp).Of fset(1,
0)) + 1 & "=""),"""",0)"

Any suggestions?

Thank you so much
Terry V





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Programmatically increase the row # in a formula

Bob
This gives me an application defined error.

Thank you :)
Terry
"Bob Phillips" wrote in message
...
Terry,

Try this

Selection.AutoFill Destination:=Selection.Resize(2, 1),

Type:=xlFillDefault

The 2 is the number of rows to copy the formula to, 1 is the number of
columns. Adjust to suit

--

HTH

RP

"Terry V" wrote in message
...
Hello
This is a really silly questions but here it goes.
I have a sheet where in a cell I have this formula:
=IF(AND($C30,$A3=""),"",0)
It works fine and does what I want. However, programmatically, I place

the
formula in the next cell down from it (just like the copy handle

dragging
down 1 row).

This is what the macro recorder gives me:
Selection.AutoFill Destination:=Range("D3:D4"), Type:=xlFillDefault
Range("D3:D4").Select

Which makes sense, but I cannot hard code the Cell addresses (except in

the
first on which is already in the cell).

Programmatically, how can I increase the row number by 1?

I tried this ** LOL ** but of course it did not work: ======= what a

mess

Sheets("Sheet3").Range("D65536").End(xlUp).Offset( 1, 0).Formula =
"=IF(AND($C" & Rows(Sheets("Sheet3").Range("D65536").End(xlUp).Of fset(1,

0))
+ 1 & "0,$A" &

Rows(Sheets("Sheet3").Range("D65536").End(xlUp).Of fset(1,
0)) + 1 & "=""),"""",0)"

Any suggestions?

Thank you so much
Terry V







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Programmatically increase the row # in a formula

Really, it worked for me.

What cells are you selecting, what formula does it hold, and what Excel
version?

Oh by the way, it might be wrap-arouund. Try

Selection.AutoFill Destination:=Selection.Resize(2, 1), _
Type:=xlFillDefault
--

HTH

RP

"Terry V" wrote in message
...
Bob
This gives me an application defined error.

Thank you :)
Terry
"Bob Phillips" wrote in message
...
Terry,

Try this

Selection.AutoFill Destination:=Selection.Resize(2, 1),

Type:=xlFillDefault

The 2 is the number of rows to copy the formula to, 1 is the number of
columns. Adjust to suit

--

HTH

RP

"Terry V" wrote in message
...
Hello
This is a really silly questions but here it goes.
I have a sheet where in a cell I have this formula:
=IF(AND($C30,$A3=""),"",0)
It works fine and does what I want. However, programmatically, I

place
the
formula in the next cell down from it (just like the copy handle

dragging
down 1 row).

This is what the macro recorder gives me:
Selection.AutoFill Destination:=Range("D3:D4"), Type:=xlFillDefault
Range("D3:D4").Select

Which makes sense, but I cannot hard code the Cell addresses (except

in
the
first on which is already in the cell).

Programmatically, how can I increase the row number by 1?

I tried this ** LOL ** but of course it did not work: ======= what a

mess

Sheets("Sheet3").Range("D65536").End(xlUp).Offset( 1, 0).Formula =
"=IF(AND($C" &

Rows(Sheets("Sheet3").Range("D65536").End(xlUp).Of fset(1,
0))
+ 1 & "0,$A" &

Rows(Sheets("Sheet3").Range("D65536").End(xlUp).Of fset(1,
0)) + 1 & "=""),"""",0)"

Any suggestions?

Thank you so much
Terry V









  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Programmatically increase the row # in a formula

What I ended up doing is finding the cell using .Range("D65536").End(xlUp),
then placed that cell into a variable and used the .copy then offset by 1
and used PasteSpecial xlPasteFormulas and it did all I needed to do.

But thank you so much Bob

Terry V
"Bob Phillips" wrote in message
...
Really, it worked for me.

What cells are you selecting, what formula does it hold, and what Excel
version?

Oh by the way, it might be wrap-arouund. Try

Selection.AutoFill Destination:=Selection.Resize(2, 1), _
Type:=xlFillDefault
--

HTH

RP

"Terry V" wrote in message
...
Bob
This gives me an application defined error.

Thank you :)
Terry
"Bob Phillips" wrote in message
...
Terry,

Try this

Selection.AutoFill Destination:=Selection.Resize(2, 1),

Type:=xlFillDefault

The 2 is the number of rows to copy the formula to, 1 is the number of
columns. Adjust to suit

--

HTH

RP

"Terry V" wrote in message
...
Hello
This is a really silly questions but here it goes.
I have a sheet where in a cell I have this formula:
=IF(AND($C30,$A3=""),"",0)
It works fine and does what I want. However, programmatically, I

place
the
formula in the next cell down from it (just like the copy handle

dragging
down 1 row).

This is what the macro recorder gives me:
Selection.AutoFill Destination:=Range("D3:D4"), Type:=xlFillDefault
Range("D3:D4").Select

Which makes sense, but I cannot hard code the Cell addresses (except

in
the
first on which is already in the cell).

Programmatically, how can I increase the row number by 1?

I tried this ** LOL ** but of course it did not work: ======= what

a
mess

Sheets("Sheet3").Range("D65536").End(xlUp).Offset( 1, 0).Formula =
"=IF(AND($C" &

Rows(Sheets("Sheet3").Range("D65536").End(xlUp).Of fset(1,
0))
+ 1 & "0,$A" &

Rows(Sheets("Sheet3").Range("D65536").End(xlUp).Of fset(1,
0)) + 1 & "=""),"""",0)"

Any suggestions?

Thank you so much
Terry V











Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Programmatically add a Formula in a worksheet? circuit_breaker Excel Worksheet Functions 3 July 6th 09 02:53 PM
Formula to get increase by 80% Abdul[_2_] Excel Worksheet Functions 1 March 25th 09 03:56 PM
Increase by % Formula Trying Hard New Users to Excel 6 July 19th 08 12:33 AM
Number in cell increase with increase in font size. Value increases with increase in font.[_2_] Excel Discussion (Misc queries) 2 August 9th 07 01:58 PM
Formula produces wrong result when data cells filled programmatically Bob Graham Excel Programming 2 September 12th 03 05:51 AM


All times are GMT +1. The time now is 12:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"