我想做以下几点:
一个。 Cell A2是产品下拉列表:手机,笔记本,电视
湾单元格B2是数量的下拉列表:1,2,3,4,5
℃。 C2到C6将显示基于A2和B2的数据。
示例:
if A2="Cellphone" and B2=2; C2="Cellphone Serial Number", C3="Cellphone Serial Number"
If A2="Notebook" and B2=5; C2="Notebook Serial Number", C3="Notebook Serial Number", C4="Notebook Serial Number", C5="Notebook Serial Number", C6="Notebook Serial Number"
如何在excel或VBA中执行上述操作?
谢谢。
答案 0 :(得分:0)
以下是
上面的伪代码的vba转换Sub test()
If Range("A2") = "Cellphone" And Range("B2") = 2 Then
'no need to reference each cell individually
Range("C2:C3") = "Cellphone Serial Number"
ElseIf Range("A2") = "Notebook" And Range("B2") = 5 Then
Range("C3:C6") = "Notebook Serial Number"
End If
End Sub