我正在尝试让userform输入excel表中的值。 userform将coloumn与日期进行比较,当它进入所选日期的coloumn时,它选择其中的单元格。我无法在所有选定的颜色中输入值。
这是我的代码
Public Sub datevalue()
Dim j As Long
For j = 4 To 100
If ActiveSheet.Cells(1, j).Value = DTPicker1.Value Then
ActiveSheet.Cells(1, j).Select
ActiveCell.offset(1).Select
Call TextBox1_Change
ActiveCell.offset(12).Select
Call TextBox2_Change
ActiveCell.offset(1).Select
Call TextBox3_Change
ActiveCell.offset(1).Select
Call TextBox4_Change
ActiveCell.offset(2).Select
Call TextBox5_Change
Exit For
End If
Next
If DTPicker1.Value = "1/1/2003" Then
MsgBox ("Select the date"), vbExclamation
End If
Private Sub TextBox1_Change()
With ActiveSheet
ActiveCell.Value = TextBox1.Text
End With
End Sub
Private Sub TextBox2_Change()
With ActiveSheet
ActiveCell.Value = TextBox2.Text
End With
End Sub
Private Sub TextBox3_Change()
With ActiveSheet
ActiveCell.Value = TextBox3.Text
End With
End Sub
Private Sub TextBox4_Change()
With ActiveSheet
ActiveCell.Value = TextBox3.Text
End With
End Sub
Private Sub TextBox5_Change()
With ActiveSheet
ActiveCell.Value = TextBox3.Text
End With
End Sub
我应该在代码中添加什么内容,以便在每个文本框中弹出userform以填充值,然后继续下一个文本框。 我对VBA编程很新,仅仅一周时间。 请帮忙