Robert_Conklin
Board Regular
- Joined
- Jun 19, 2017
- Messages
- 173
- Office Version
- 365
- Platform
- Windows
- MacOS
I have set up some command buttons that open user-forms for my end users to enter data into in order to update tabs in the workbook. I have set up three tables, one in each of the three tabs. The problem is, in two of the three tables a new line is not being created in the table. It just overwrites the lines below the table. In the other code, the same thing is happening, but it is overwriting the information in the first(top) line in the table.
My goal is when the end users clicks the submit button on the user-form, a NEW line is created in the table that copies all settings and formulae from the line above as well and write the data that was entered in to the user-form. Below is the code:
The PGS ScoreCard tab and the PGSSavingsTimeline(Projections) tab are the two that overwrite the data in the lines below the table. The PGSSavingsTimeline(Roll-Up) tab is overwriting the data in the first (top) line of the table.
My goal is when the end users clicks the submit button on the user-form, a NEW line is created in the table that copies all settings and formulae from the line above as well and write the data that was entered in to the user-form. Below is the code:
Code:
Private Sub cb01_Click()With Sheets("PGS Score Card")
iRow = .ListObjects("PGSSC_tbl").Range.Columns(2).Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
.Cells(iRow, 3).Value = tbx01.Value
.Cells(iRow, 5).Value = tbx21.Value
.Cells(iRow, 6).Value = tbx02.Value
.Cells(iRow, 7).Value = tbx18.Value
End With
With Sheets("PGSSavingsTimeline(Projections)")
iRow = .ListObjects("PGSSTP_tbl").Range.Columns(3).Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
.Cells(iRow, 2).Resize(, 22).Value = Array(cbx13.Value, tbx01.Value, cbx02.Value, tbx21.Value, tbx22.Value, tbx03.Value, cbx04.Value, cbx05.Value, _
cbx06.Value, cbx07.Value, tbx04.Value, cbx08.Value, tbx18.Value, tbx05.Value, tbx06.Value, tbx07.Value, cbx09.Value, tbx09.Value, tbx08.Value, _
, tbx23.Value, tbx24.Value)
End With
With Sheets("PG&S Savings Timeline (Roll-up)")
iRow = .ListObjects("PGSSTRu_tbl").Range.Columns(3).Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
.Cells(iRow, 2).Resize(, 35).Value = Array(, tbx01.Value, , cbx02.Value, tbx21.Value, , , cbx10.Value, cbx12.Value, tbx10.Value, cbx13.Value, tbx11.Value, _
cbx11.Value, tbx12.Value, , , , , , , , , , , , tbx13.Value, , tbx19.Value, tbx15.Value, , , , tbx20.Value, tbx17.Value, tbx14.Value)
End With
For Each ctrl In Controls
If TypeName(ctrl) = "TextBox" Or TypeName(ctrl) = "ComboBox" Then ctrl.Value = ""
Next ctrl
LB_01.ListIndex = -1
Call UserForm_Initialize
End Sub
The PGS ScoreCard tab and the PGSSavingsTimeline(Projections) tab are the two that overwrite the data in the lines below the table. The PGSSavingsTimeline(Roll-Up) tab is overwriting the data in the first (top) line of the table.
Last edited: