ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   vba code (https://www.excelbanter.com/excel-discussion-misc-queries/62629-vba-code.html)

[email protected]

vba code
 
why does this code not input a formula into cells
e5 to end of data

Range("D6").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 1).Range("A1").Select
Do Until Range("E5").Select
ActiveCell.FormulaR1C1 = "=R2C8/(RC[-2]-RC[-4])"
ActiveCell.Offset(-1, 0).Range("a1").Select
Loop


Ken Johnson

vba code
 
Hi agw,

Try the following change:


Do Until ActiveCell.Address = "$E$5"

Ken Johnson


Dave Peterson

vba code
 
It looks like you're using column D to get the last used cell.

If that's true:

with activesheet
.range("E5:E" & .cells(.rows.count,"D").end(xlup).row).formular1c1 _
= "=R2C8/(RC[-2]-RC[-4])"
end with

wrote:

why does this code not input a formula into cells
e5 to end of data

Range("D6").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 1).Range("A1").Select
Do Until Range("E5").Select
ActiveCell.FormulaR1C1 = "=R2C8/(RC[-2]-RC[-4])"
ActiveCell.Offset(-1, 0).Range("a1").Select
Loop


--

Dave Peterson


All times are GMT +1. The time now is 06:59 PM.

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