读取组合框数据:运行时错误'9'



我正在尝试制作一个表格,通过使用Excel存储数据来跟踪我们的碳粉供应情况。

我正试图通过读取两个组合框中的内容来调用Excel中的数据。

当我单独运行名称组合框时,它是有效的,但当我运行模型组合框时我会得到错误9。

Private Sub cmbName_Change() 'User changed Name combo box
VarRow = Worksheets("Printers").Columns(1).Find(What:=Me.cmbName.Text).Row
Me.cmbModel.Text = Sheets("Printers").Cells(VarRow, 2).Value
End Sub
Private Sub cmbModel_Change() 'User changed Name or Model combo box
VarRow = Worksheets("PrinterModels").Columns(1).Find(What:=Me.cmbModel.Text).Row
Me.TBBlack.Text = Sheets("PrinterModels").Cells(VarRow, 2).Value
Me.TBCyan.Text = Sheets("PrinterModels").Cells(VarRow, 3).Value
Me.TBMagenta.Text = Sheets("PrinterModels").Cells(VarRow, 4).Value
Me.TBYellow.Text = Sheets("PrinterModels").Cells(VarRow, 5).Value
End Sub

谢谢吴!

他在下面的评论是对我的问题的回答,我错误地调用了我的床单。当我运行PrinterModels.Columns(1(时,错误退出,代码按照我的意愿运行。再次感谢所有发表评论的人!

"试试工作表("打印机型号"(,然后,工作表中给出的参数是工作表的名称,而不是代号。备选方案我认为您可以通过PrinterModels.Columns(1(引用它的代号;

相关内容

最新更新