我想根據Excel中第一列的選定下拉選項自動填充下一列。根據所選菜單使用vba自動填充excel上的特定列
下面,我認爲最初的代碼樣本,但似乎我的做法是不正確。
Private Sub WorksheetStore_Change(ByVal Target As Range)
Dim i As Integer
Dim intCol As Integer
intCol = shtStoreGroup.Range("A")
If Not IsEmpty(Target.value) And intCol > 1 And Target.Columns.Count = 1 And Target.Column = intCol And Target.Row > Start_Row Then
For i = Target.Row To Target.Row + Target.Rows.Count - 1
If shtStoreGroup.Columns(intCol).Rows(i).value = "Create" Then
shtStoreGroup.Columns(intCol + 2).Rows(i).value = "N/A"
shtStoreGroup.Columns(intCol + 3).Rows(i).value = "Test"
Next i
End If
End Sub
我想「WorksheetStore」是您的工作表的名稱。但是當你的組合框值發生變化時,你應該做些事情。例如:'Private Sub comboBoxName_Change()... End Sub' – tretom
或者當它失去焦點時:'Private Sub comboBoxName_LostFocus()... End Sub' – tretom
您可能想要添加更多關於涉及多少張表的細節,名稱,應該開始發生什麼,應該在哪裏觸發,... – user3598756