Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
需要vba模块为一组excel电子表格中的两列应用下拉列表框验证_Excel_Vba_Module_Listbox_Activex - Fatal编程技术网

需要vba模块为一组excel电子表格中的两列应用下拉列表框验证

需要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

我写了一些东西,但它只在一个电子表格上工作(有点),但我每个月有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")
    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%没有。