ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to find end of column data (https://www.excelbanter.com/excel-programming/395173-macro-find-end-column-data.html)

[email protected][_2_]

Macro to find end of column data
 
I have a range of data (ex: A1:F20) and in the column (g) next to the
data i have a formula that adds certain fields. I am constantly
adding rows of data, so what I want is a macro that will find the last
row of data in column F, then paste the formula from the last row of
column G down to that row. Any help is appreciated. Thanks in
advance.


Jim Thomlinson

Macro to find end of column data
 
One way...

Sub CopyFormula()
Dim rngToCopy As Range
Dim rngLast As Range

Set rngToCopy = Cells(Rows.Count, "G").End(xlUp)
Set rngLast = Cells(Rows.Count, "F").End(xlUp)

If rngToCopy.Row < rngLast.Row Then _
rngToCopy.Copy Range(rngToCopy.Offset(1, 0), rngLast.Offset(0, 1))

End Sub
--
HTH...

Jim Thomlinson


" wrote:

I have a range of data (ex: A1:F20) and in the column (g) next to the
data i have a formula that adds certain fields. I am constantly
adding rows of data, so what I want is a macro that will find the last
row of data in column F, then paste the formula from the last row of
column G down to that row. Any help is appreciated. Thanks in
advance.



[email protected][_2_]

Macro to find end of column data
 
Perfect. Thanks!

On Aug 9, 1:18 pm, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote:
One way...

Sub CopyFormula()
Dim rngToCopy As Range
Dim rngLast As Range

Set rngToCopy = Cells(Rows.Count, "G").End(xlUp)
Set rngLast = Cells(Rows.Count, "F").End(xlUp)

If rngToCopy.Row < rngLast.Row Then _
rngToCopy.Copy Range(rngToCopy.Offset(1, 0), rngLast.Offset(0, 1))

End Sub
--
HTH...

Jim Thomlinson



" wrote:
I have a range of data (ex: A1:F20) and in the column (g) next to the
data i have a formula that adds certain fields. I am constantly
adding rows of data, so what I want is a macro that will find the last
row of data in column F, then paste the formula from the last row of
column G down to that row. Any help is appreciated. Thanks in
advance.- Hide quoted text -


- Show quoted text -





All times are GMT +1. The time now is 02:08 PM.

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