求一段excel的函数代码啊,在线等,急着用啊!急急急!(提问如下)

2024-11-27 03:59:45
推荐回答(3个)
回答1:

能否用B列做辅助列
在B1输入
=IF(A1="","",CHOOSE(RANDBETWEEN(1,3),"A","B","C"))
当A列输入内容时,B列就随机出现A、B、C三个字母
然后在把AB列合并起来

回答2:

好像很难在原单元格做自动修改啊,尝试写了个Worksheet_Change(ByVal Target As Range),结果因为最后添加了一个字符,于是再次执行,执行后又加一个字符,第三次执行……,等高人

回答3:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.EnableEvents = False
Target = Target & Mid("ABC", Int(Rnd * 3 + 1), 1)
Application.EnableEvents = True
[A1].Select
End If
End Sub