我有一排单元格,根据我选择的选项按钮,会显示一定范围的值。它不是基于任何方程或任何逻辑。我需要在多个单元格中显示一组特定的值。
Private Sub OptionButton1_Click()
If OptionButton1.Value = True Then Range("B3","AF3").Value =
End Sub
在这种情况下,如何在单元格中指示多个值?我会先将所有值放入某种数组中,然后将数组输入.Value
吗?谢谢!
答案 0 :(得分:3)
我最终使用的方法如下。
Worksheets("Sheet1").Range("B3","AF3").Value = Worksheets("Sheet2").Range("B3","AF3").Value
答案 1 :(得分:1)
可能有更优雅的方式,但这是一种方法:
Sub test()
Dim strArray(0 To 2) As String
Dim rng As Range
Dim cell As Range
Dim counter As Long
Set rng = Range("A3,B7,G5")
counter = 0
strArray(0) = "Value1"
strArray(1) = "Value2"
strArray(2) = "Value3"
For Each cell In rng
cell.Value = strArray(counter)
counter = counter + 1
Next cell
End Sub