Autofill row from above row (VBA)

1newguy

New Member
Joined
Jul 11, 2019
Messages
3
This code used to add a row to a table, My problem is, the row that is added does not contain formulas, I would like all formulas in the row above to be carried down to the newly inserted row.
Any suggestions?



VBA Code:
[
Option Explicit
Dim LObj As ListObject

Private Sub Removeusernow_Click()
Dim i&
i = ComboBox1.ListIndex
If i = -1 Then MsgBox "Non-existent name: remove cancelled.": Exit Sub
ComboBox1.RowSource = ""
LObj.ListRows(1 + i).Delete
ComboBox1.RowSource = LObj.Name
Unload Me
End Sub

Private Sub UserForm_Initialize()
Set LObj = Range("Tabla1").ListObject
ComboBox1.RowSource = LObj.Name
End Sub

Private Sub Addusernow_Click()
Dim i&
i = ComboBox1.ListIndex
If i > -1 Then MsgBox "Existing name: addition cancelled.": Exit Sub
ComboBox1.RowSource = ""
If ComboBox1 < LObj.Range(2, 1) Then
  LObj.ListRows.Add(1).Range(1) = ComboBox1
Else
  i = WorksheetFunction.Match(ComboBox1, LObj.ListColumns(1).DataBodyRange)
  If i < LObj.ListRows.Count Then
    LObj.ListRows.Add(1 + i).Range(1) = ComboBox1
    
  Else
    LObj.ListRows.Add.Range(1) = ComboBox1
  End If
End If
ComboBox1.RowSource = LObj.Name
Unload Me
End Sub

/CODE]
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,214,979
Messages
6,122,551
Members
449,088
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top