EXCEL中,如何用VBA向单元格赋值?
我要的问题不是把一个单元格的内容复制粘贴到另一个单元格里,而是:如何把一固定内容在点击按钮后赋于另一单元格??如,把"祝你快乐!"填于B1单元格中?请教高手!!补充一下:...
我要的问题不是把一个单元格的内容复制粘贴到另一个单元格里,而是:如何把一固定内容在点击按钮后赋于另一单元格??如,把"祝你快乐!"填于B1单元格中?
请教高手!!
补充一下:刚才那位朋友回答的,是把固定内容赋予"选中的任一单元格",而我想要的是,赋予固定单元格B1,能否实现啊?? 展开
请教高手!!
补充一下:刚才那位朋友回答的,是把固定内容赋予"选中的任一单元格",而我想要的是,赋予固定单元格B1,能否实现啊?? 展开
3个回答
展开全部
ActiveCell.FormulaR1C1 = "祝你快乐!"
你看是这样吗?
你看是这样吗?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Sub sss()
Dim myRng As Range
Dim c As Range
Dim myColor As Integer
Dim i As Integer
Dim jg1, jg2, jg3, jg4, jg5 As Integer
Dim 起始行 As Integer
Dim 结束行 As Integer
起始行 = 2 '设置起始行
结束行 = 10 '设置结束行
For i = 起始行 To 结束行 '开始循环计算
Set myRng = Range("o" & i) '赠品1获取价格1
jg1 = Jgjsq(myRng.Value)
Set myRng = Range("P" & i) '赠品2获取价格2
jg2 = Jgjsq(myRng.Value)
Set myRng = Range("Q" & i) '赠品3获取价格3
jg3 = Jgjsq(myRng.Value)
Set myRng = Range("R" & i) '赠品4获取价格4
jg4 = Jgjsq(myRng.Value)
Set myRng = Range("S" & i) '赠品4获取价格4
jg5 = Jgjsq(myRng.Value)
Worksheets("工资核算明细表").Range("U" & i).Value = jg1 + jg2 + jg3 + jg4 + jg5
Next i
End Sub
Function Jgjsq(Zp As String)
Select Case Zp
Case "钢化膜"
jg = 2
Case "保护壳"
jg = 1
Case "全包钢化膜"
jg = 5
Case "耳机"
jg = 3.5
Case "青花瓷碗2件套"
jg = 3.7
Case "平底锅4件套"
Case "电饼铛"
jg = 56
Case "指环扣"
jg = 2.5
Case "钻石玻璃碗6件套"
jg = 14
Case "精品茶具7件套"
jg = 17
Case "九阳电饭煲"
jg = 67
End Select
Jgjsq = jg '返回价格
End Function
已解决
Dim myRng As Range
Dim c As Range
Dim myColor As Integer
Dim i As Integer
Dim jg1, jg2, jg3, jg4, jg5 As Integer
Dim 起始行 As Integer
Dim 结束行 As Integer
起始行 = 2 '设置起始行
结束行 = 10 '设置结束行
For i = 起始行 To 结束行 '开始循环计算
Set myRng = Range("o" & i) '赠品1获取价格1
jg1 = Jgjsq(myRng.Value)
Set myRng = Range("P" & i) '赠品2获取价格2
jg2 = Jgjsq(myRng.Value)
Set myRng = Range("Q" & i) '赠品3获取价格3
jg3 = Jgjsq(myRng.Value)
Set myRng = Range("R" & i) '赠品4获取价格4
jg4 = Jgjsq(myRng.Value)
Set myRng = Range("S" & i) '赠品4获取价格4
jg5 = Jgjsq(myRng.Value)
Worksheets("工资核算明细表").Range("U" & i).Value = jg1 + jg2 + jg3 + jg4 + jg5
Next i
End Sub
Function Jgjsq(Zp As String)
Select Case Zp
Case "钢化膜"
jg = 2
Case "保护壳"
jg = 1
Case "全包钢化膜"
jg = 5
Case "耳机"
jg = 3.5
Case "青花瓷碗2件套"
jg = 3.7
Case "平底锅4件套"
Case "电饼铛"
jg = 56
Case "指环扣"
jg = 2.5
Case "钻石玻璃碗6件套"
jg = 14
Case "精品茶具7件套"
jg = 17
Case "九阳电饭煲"
jg = 67
End Select
Jgjsq = jg '返回价格
End Function
已解决
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询