如何增加循环中的字符variables〜VBA
我需要在Excel电子表格中使用VBA进行循环打印。
我必须从单元格E1开始,直到用户在文本框中input的数字。 我需要在单元格E1,F2,G3 …中打印一个string。
我用了以下,但它没有工作:
Dim j As Integer, N As Integer Dim i As String N = InputBox("Plese enter the number of Processes", "Enter data", "Enter number here") i = "E" For j = 1 To N Range(i & j).Value = "Random text" i = i + 1 Next j
谢谢您的帮助 :)
我需要这个截图中的输出。
使用“Cells(rowIndex,columnIndex)”属性,该属性接受可以递增的行和列索引的数字
Dim j As Integer, N As Integer, i As Integer N = InputBox("Plese enter the number of Processes", "Enter data", "Enter number here") i = 5 For j = 1 To N Cells(j,i).Value = "Random text" i = i + 1 Next j
使用Range.Offset
,从“E1”开始并经过N
值。
试试下面的代码:
Dim N As Long Dim i As Long N = InputBox("Please enter the number of Processes", "Enter data", "Enter number here") For i = 1 To N Range("E1").Offset(i, i).Value = "Random text" Next i