Insert line in second to the last row.

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Greetings, I'm polishing up my project and I discovered by VBA does not work on an Excel Table, but it is just fine on a normal worksheet. The long story short is if I can insert a line in the second to the last line that is filled it should take care of my blank issues on my pivot tables/splicers. I'm thinking it will keep "my data source" updated. Having to use the whole worksheet is not streamlining my project. I figured second to the last line will continuing to expand the data source would do the same thing as a excel table without totally rewriting everything else. I have "Descend" and "Refresh Buttons" which keeps things in order.

This is working with a UserForm to input data in a database.



My code is

VBA Code:
Sub Submit2()
Dim sh As Worksheet
Dim iRow As Long
Set sh = ThisWorkbook.Sheets("Pallets")

If Palletform.txtRowNumber2.Value = "" Then


iRow = [Counta(Pallets!A:A)] + 1 

 Else
   iRow = Palletform.txtRowNumber2.Value

   End If
With sh
     If Palletform.txtDate <> "" Then .Cells(iRow, 1).Value = CDate(Palletform.txtDate)
     .Cells(iRow, 2) = Palletform.txtDestination.Value
     .Cells(iRow, 3) = Palletform.txtPalletID.Value
     .Cells(iRow, 4) = Palletform.txtTcns.Value
     .Cells(iRow, 5) = Palletform.txtPieces.Value
     .Cells(iRow, 6) = Palletform.txtWeight.Value
     .Cells(iRow, 7) = Palletform.cmbShipment.Value
     .Cells(iRow, 9) = Palletform.cmbSupport.Value
     .Cells(iRow, 10) = Palletform.txtRemarks.Value

  End With

End Sub



Thank you,
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Greetings, I'm polishing up my project and I discovered by VBA does not work on an Excel Table, but it is just fine on a normal worksheet. The long story short is if I can insert a line in the second to the last line that is filled it should take care of my blank issues on my pivot tables/splicers. I'm thinking it will keep "my data source" updated. Having to use the whole worksheet is not streamlining my project. I figured second to the last line will continuing to expand the data source would do the same thing as a excel table without totally rewriting everything else. I have "Descend" and "Refresh Buttons" which keeps things in order.

This is working with a UserForm to input data in a database.



My code is

VBA Code:
Sub Submit2()
Dim sh As Worksheet
Dim iRow As Long
Set sh = ThisWorkbook.Sheets("Pallets")

If Palletform.txtRowNumber2.Value = "" Then


iRow = [Counta(Pallets!A:A)] + 1

 Else
   iRow = Palletform.txtRowNumber2.Value

   End If
With sh
     If Palletform.txtDate <> "" Then .Cells(iRow, 1).Value = CDate(Palletform.txtDate)
     .Cells(iRow, 2) = Palletform.txtDestination.Value
     .Cells(iRow, 3) = Palletform.txtPalletID.Value
     .Cells(iRow, 4) = Palletform.txtTcns.Value
     .Cells(iRow, 5) = Palletform.txtPieces.Value
     .Cells(iRow, 6) = Palletform.txtWeight.Value
     .Cells(iRow, 7) = Palletform.cmbShipment.Value
     .Cells(iRow, 9) = Palletform.cmbSupport.Value
     .Cells(iRow, 10) = Palletform.txtRemarks.Value

  End With

End Sub



Thank you,
The name of the table is "table 1".
 
Upvote 0
Thank you, I do have the situation resolved. I continue to work on these, even while I hope an answer may appear. Much appreciated.
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,572
Members
448,972
Latest member
Shantanu2024

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