Macro to add a line at the bottom of a table with prefilled functi

  • Thread starter Thread starter Maypop
  • Start date Start date
M

Maypop

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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top