2016-07-10 5 views
0

私のユーザーフォームには、テーブルの特定のセルに値を表示する必要があるテキストボックスはほとんどありません。どのように私はこれらの値をセルに印刷するのですか?あなたのコードで表示と同じようにテキストボックスの値をセルにどのように表示するのですか?

'add a new employee to the bottom of the list 

'last_row = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row 

Cells(last_row, 1) = Box_FirstName.Value 
Columns("A:A").EntireColumn.AutoFit 

Cells(last_row, 2) = Box_LastName.Value.Value 
Columns("B:B").EntireColumn.AutoFit 

Cells(last_row, 3) = Box_Adress.Value.Value 
Columns("C:C").EntireColumn.AutoFit 

Cells(last_row, 4) = Box_ID.Value.Value 
Columns("D:D").EntireColumn.AutoFit 

答えて

2

Cells(1, 1) = TextBox1.Value 

ジャスト場合は、セルをアドレスするために使用する変数のいずれも0

編集 に設定されていないことを確認してくださいあなたは文字列変数としてBox_FirstNameを使用して、その後、時々UserFromを変更します:

Dim Form_Name as Object 

Set Form_Name = UserForm1 'UserFrom name 
Cells(1, 1) = Form_Name.Controls(Box_FistName).Value 
+1

複数のユーザーフォームを持っている場合は、TextBox名の前に 'Form_Name'を追加することをお勧めします。 –

+0

私は文字列変数として意味しました、ごめんなさい、その部分を忘れました。 –