作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在学习 VBA Excel,但我的项目有问题
这里的代码
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim score As String, result As String
score = Range("A1").Value
If score = "1" Then
result = "book1"
ElseIf score = "2" Then
result = "book2"
Else
result = "wrong"
End If
Range("A1").Value = result
End Sub
最佳答案
您可以使用 OR 运算符为 book1 和 book2 添加一个条件。
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim score As String, result As String
score = Range("A1").Value
If score = "1" Or score="book1" Then
result = "book1"
ElseIf score = "2" Or score="book2" Then
result = "book2"
Else
result = "wrong"
End If
Range("A1").Value = result
End Sub
关于excel - 在 VBA Excel 中创建插入语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60050426/
我是一名优秀的程序员,十分优秀!