Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试向变量添加范围,然后该变量将是文本框中显示的文本。到目前为止,我所做的是以下代码:
Private Sub TextBox1_Change() Dim text1 As String text1 = Sheet16.Range("C21:D40").Value Sheet15.TextBox1.Value = text1 End Sub
当我尝试运行它时出现错误“类型不匹配”。请任何建议将不胜感激。
您不能将范围分配给字符串变量。
如果您想将范围相加或求和,您的代码将类似于以下代码:
Private Sub myAddingFunction() Dim text1As String text1= Application.Sum(Range("C21:D40")) Range("c1").Value = text1 End Sub
其中 Range("c1") 可以替换为 Sheet15.TextBox1.Value