根据单选buttonselect分配单元格值

我想分配一个单元格的值,当用户select一个单选button时,值取决于所选的单选。 单选button是在窗体上,我试图将值分配给一个名为“工作区”

这里是我的代码

Private Sub OK_Click() 'A3 Assignment If OpQ1_01_1.Value = True Then Sheets("Workpace").Cells("A3").Value = "1" ElseIf OpQ1_01_2.Value = True Then Sheets("Workpace").Cells("A3").Value = "2" ElseIf OpQ1_01_3.Value = True Then Sheets("Workspace").Cells(A3).Value = "3" ElseIf OpQ1_01_4.Value = True Then Sheets("Workpace").Cells("A3").Value = "4" ElseIf OpQ1_01_5.Value = True Then Sheets("Workpace").Cells("A3").Value = "5" ElseIf OpQ1_01_6.Value = True Then Sheets("Workpace").Cells("A3").Value = "6" End If 

至于我可以告诉它应该工作,工作表是在那里和一个单元格A3,但我不断收到一个消息,说明“应用程序定义或对象定义的错误”这不告诉我什么,但它突出了分配部分我select的单选button的代码(在这种情况下是第三个选项)

在这种情况下debugging突出显示了这块代码

 Sheets("Workspace").Cells(A3).Value = "3" 

Cells更改为这样的Range

 Sheets("Workspace").Range("A3").Value = "3" 

或者如果你想坚持像这样的Cells

 Sheets("Workspace").Cells(3, 1).Value = "3" '~~> where 3 is the row number and 1 is the column number. 

工作表的名称似乎在代码中缺less“s”(您在代码中键入“工作空间”而不是“工作空间”