ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   vba entering a formula in a certain cell (https://www.excelbanter.com/excel-programming/398651-vba-entering-formula-certain-cell.html)

umpire_43[_2_]

vba entering a formula in a certain cell
 
Hi there,

I need some help with vba programming by creating a formula in cell g6

The Formula i like to enter in this cell = f6 - e6, but then each month the
number of rows will change. I need to be able to copy this formula down
based on the number of rows under row 6.

Can you help me?
Thanks





Gary Keramidas

vba entering a formula in a certain cell
 
see if this is what you need:

Sub insert_formulas()
Dim ws As Worksheet
Dim lastorw As Long
Set ws = Worksheets("Sheet1")
Dim lastrow As Long
lastrow = ws.Cells(Rows.Count, "E").End(xlUp).Row

With ws.Range("G6:G" & lastrow)
.Formula = "=F6-E6"
End With
End Sub

--


Gary


"umpire_43" wrote in message
...
Hi there,

I need some help with vba programming by creating a formula in cell g6

The Formula i like to enter in this cell = f6 - e6, but then each month the
number of rows will change. I need to be able to copy this formula down
based on the number of rows under row 6.

Can you help me?
Thanks







umpire_43

vba entering a formula in a certain cell
 
Hi Gary,

Worked great thanks


"Gary Keramidas" wrote:

see if this is what you need:

Sub insert_formulas()
Dim ws As Worksheet
Dim lastorw As Long
Set ws = Worksheets("Sheet1")
Dim lastrow As Long
lastrow = ws.Cells(Rows.Count, "E").End(xlUp).Row

With ws.Range("G6:G" & lastrow)
.Formula = "=F6-E6"
End With
End Sub

--


Gary


"umpire_43" wrote in message
...
Hi there,

I need some help with vba programming by creating a formula in cell g6

The Formula i like to enter in this cell = f6 - e6, but then each month the
number of rows will change. I need to be able to copy this formula down
based on the number of rows under row 6.

Can you help me?
Thanks









All times are GMT +1. The time now is 03:09 AM.

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