需要vba模块为一组excel电子表格中的两列应用下拉列表框验证
我写了一些东西,但它只在一个电子表格上工作(有点),但我每个月有18个,我的目标是每个月编写一个模块并将其导入所有模块。出于某种原因,这种工作从第4行开始,而不是第2行 我做错了什么需要vba模块为一组excel电子表格中的两列应用下拉列表框验证,excel,vba,module,listbox,activex,Excel,Vba,Module,Listbox,Activex,我写了一些东西,但它只在一个电子表格上工作(有点),但我每个月有18个,我的目标是每个月编写一个模块并将其导入所有模块。出于某种原因,这种工作从第4行开始,而不是第2行 我做错了什么 Option Explicit Private Sub Workbook_Open() With dataValKeep() Dim lrow As Long Dim i As Long Set sht = Sheets("Inventory_Risk_beta1") lr
Option Explicit
Private Sub Workbook_Open()
With dataValKeep()
Dim lrow As Long
Dim i As Long
Set sht = Sheets("Inventory_Risk_beta1")
lrow = Sheets("Inventory_Risk_beta1").Cells(Sheets("Inventory_Risk_beta1").Rows.Count, "A").End(xlUp).Row
With sht.Range("AN2:AN" & lrow).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Formula1:="Rework,Shelf Life Extension,Change in Demand,Quality Issue,End of Life,NPI,Transfer and Charge,Older Lot / Batch,Other"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End With
With dataValScrap()
Dim lrow As Long
Dim i As Long
Set sht = Sheets("Inventory_Risk_beta1")
lrow = Sheets("Inventory_Risk_beta1").Cells(Sheets("Inventory_Risk_beta1").Rows.Count, "A").End(xlUp).Row
With sht.Range("AO2:AO" & lrow).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Formula1:="Rework,Shelf Life Extension,Change in Demand,Quality Issue,End of Life,NPI,Transfer and Charge,Older Lot / Batch,Other"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End With
End Sub
dataValKeep()的
和dataValScrap()的是什么?
?每列有一个列表框(列名为“Keep”和“Scrap”)。将此代码复制并粘贴到另一个电子表格的新模块中会导致任何行或列上都没有列表框,即100%没有。