ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to add a line at the bottom of a table with prefilled functi (https://www.excelbanter.com/excel-programming/422091-macro-add-line-bottom-table-prefilled-functi.html)

Maypop

Macro to add a line at the bottom of a table with prefilled functi
 
I need to create a macro to add a line to the bottom of an existing table but
it needs to prefill the same functions as the rest of the rows in the table
(each column has the same function but it is specific to the row) I also need
it to remove all data that is not a function. Effectively giving you a new
row to input new data for that row. Any help on where to start would be
greatly appreciated.

RadarEye

Macro to add a line at the bottom of a table with prefilledfuncti
 
On 7 jan, 14:06, Maypop wrote:
I need to create a macro to add a line to the bottom of an existing table but
it needs to prefill the same functions as the rest of the rows in the table
(each column has the same function but it is specific to the row) I also need
it to remove all data that is not a function. Effectively giving you a new
row to input new data for that row. Any help on where to start would be
greatly appreciated.


Hi Maypop,

In Excel 2003 I have created this macro which copies down all
functions of a row.

Sub CopyFunctionsOnly()
Dim lastRow As Long
Dim lastCol As Long
Dim loopCol As Long

lastRow = Cells(Cells.Rows.Count, 1).End(xlUp).Row
lastCol = Cells(1, Cells.Columns.Count).End(xlToLeft).Column
Cells(lastRow, 1).Select
For loopCol = 1 To lastCol
If Not IsEmpty(Cells(lastRow, loopCol)) Then
With Cells(lastRow, loopCol)
If Not .Formula = .Text Then
Cells(lastRow, loopCol).Resize(2, 1).Select
Selection.FillDown
End If
End With
End If
Next
End Sub

HTH,

Wouter


All times are GMT +1. The time now is 04:06 AM.

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