を選択した場合、私は私がの一番下に追加されるデータの新しい行を探していますコードのビットを持っているワークシート上の特定のテーブルに入力されましたワークシートの表移入する必要があるワークシートは、Sheet3(「データシート」)またはタブ上のデータシートだけです。は、データに新しい行を追加し、特定のリストボックスの項目がエクセル2013 VBAに</p> <p>を使用して
ワークシートには2つのテーブル(表3と表4)があり、リストボックス(StatusListBox)から選択されたカテゴリに応じて、2つのテーブルのいずれかの下部にデータ行が追加されます。
ユーザが「Live」、「Secured」または「Completed」を選択した場合、Table3を入力する必要がありますが、ユーザが「入札(Pipeline)」、「入札(交渉)」または「入札4移入されるべきである。
をIデータの新しい行を表3及び表4の両者の底部に添加される持って現在のコードである。
Private Sub AddNewButton_Click()
Dim the_sheet As Worksheet
Dim table_list_object As ListObject
Dim table_object_row As ListRow
Set the_sheet = Sheets("Data Sheet")
Set table_list_objectA = the_sheet.ListObjects("Table3")
Set table_list_objectB = the_sheet.ListObjects("Table4")
Set table_object_rowA = table_list_objectA.ListRows.Add
Set table_object_rowB = table_list_objectB.ListRows.Add
If Me.StatusListBox.ListIndex = "Secured" Then
table_list_objectA.ListRows.Add
ElseIf Me.StatusListBox.ListIndex = "Live" Then
table_list_objectA.ListRows.Add
ElseIf Me.StatusListBox.ListIndex = "Completed" Then
table_list_objectA.ListRows.Add
ElseIf Me.StatusListBox.ListIndex = "Tender (Pipeline)" Then
table_list_objectB.ListRows.Add
ElseIf Me.StatusListBox.ListIndex = "Tender (Negotiated)" Then
table_list_objectB.ListRows.Add
ElseIf Me.StatusListBox.ListIndex = "Tender (Favourable)" Then
table_list_objectB.ListRows.Add
End If
table_object_rowA.Range(1, 1).Value = ProjectNameTextBox.Value
table_object_rowB.Range(1, 1).Value = ProjectNameTextBox.Value
last_row_with_data = the_sheet.Range("A65536").End(xlUp).Row
last_row_with_data = last_row_with_data
the_sheet.Range("B" & last_row_with_data) = ClientTextBox.Value
the_sheet.Range("C" & last_row_with_data) = SectorListBox.Value
the_sheet.Range("D" & last_row_with_data) = StatusListBox.Value
the_sheet.Range("E" & last_row_with_data) = ContractValueTextBox.Value
the_sheet.Range("F" & last_row_with_data) = AFATextBox.Value
the_sheet.Range("G" & last_row_with_data) = RTPTextBox.Value
the_sheet.Range("H" & last_row_with_data) = TwentyFifteenTextBox.Value
the_sheet.Range("I" & last_row_with_data) = TwentySixteenTextBox.Value
the_sheet.Range("J" & last_row_with_data) = TwentySeventeenTextBox.Value
the_sheet.Range("K" & last_row_with_data) = TwentyEighteenTextBox.Value
the_sheet.Range("L" & last_row_with_data) = TwentyNineteenTextBox.Value
the_sheet.Range("M" & last_row_with_data) = DisciplineListBox.Value
the_sheet.Range("N" & last_row_with_data) = BoardDirectorListBox.Value
the_sheet.Range("O" & last_row_with_data) = AssociateDirectorTextBox.Value
the_sheet.Range("P" & last_row_with_data) = CommercialManagerTextBox.Value
the_sheet.Range("Q" & last_row_with_data) = ProjectManagerTextBox.Value
the_sheet.Range("R" & last_row_with_data) = QuantitySurveyorTextBox.Value
the_sheet.Range("S" & last_row_with_data) = PreConTextBox.Value
the_sheet.Range("T" & last_row_with_data) = ActualTextBox.Value
the_sheet.Range("U" & last_row_with_data) = DPStartTextBox.Value
the_sheet.Range("V" & last_row_with_data) = DPEndTextBox.Value
If Me.ProjectNameTextBox.Value = "" Then
MsgBox "Please enter Project Name.", vbExclamation, "Project Tracker Template"
Me.ProjectNameTextBox.SetFocus
End If
End Sub
任意の助けを理解するであろう。
'set'ステートメント(例えば' Set table_object_rowA = table_list_objectA.ListRows.Add')は、彼らが言うように、テーブルに行を追加しますか?また、行の値を設定する前に、 'Me.ProjectNameTextBox.Value'をチェックしてコードをさらに上に移動することもできます。 – Dave