在逗号分隔的活动单元格中打印相同的值10次

时间:2013-03-13 09:52:20

标签: excel-vba vba excel

我想使用命令按钮用逗号在单元格中打印特定值10次或更多次。任何人都可以解释如何为此编写宏吗?

单击命令按钮时,该值应在活动单元格中打印所需的时间。数据非常庞大,所以手动很难进入单个单元格并输入它。

1 个答案:

答案 0 :(得分:1)

将它放入Commandbutton_Click事件处理程序:

Dim strValueToPrint as String, strOutput as String
Dim intRepeatCount as Integer, i as Integer

strValueToPrint = "1" 'Change this to be the value that you want to repeat
for i = 1 to intRepeatCount
    strOutput = strOutput & strValueToPrint & ","
Next
Activecell.Value = strOutput