需要在Excel中使用VBA打印任何数字的表格。即每行之后的空白行。下面是我写的在连续的行中打印表格的内容,但是我不知道如何在交替的行中打印结果?

Sub table()
a = InputBox("Enter first no")
ActiveSheet.Cells.Clear
ActiveSheet.Cells(5, 4) = "TABLE OF " & a
For i = 1 To 10
c = a * i
ActiveSheet.Cells(i + 5, 4) = a
ActiveSheet.Cells(i + 5, 5) = "*"
ActiveSheet.Cells(i + 5, 6) = i
ActiveSheet.Cells(i + 5, 7) = "="
ActiveSheet.Cells(i + 5, 8).Value = c
next i
End Sub

最佳答案

Sub table()
a = InputBox("Enter first no")
n As Integer

n=6
ActiveSheet.Cells.Clear
ActiveSheet.Cells(5, 4) = "TABLE OF " & a
For i = 1 To 10
  c = a * i
  ActiveSheet.Cells(n, 4) = a
  ActiveSheet.Cells(n, 5) = "*"
  ActiveSheet.Cells(n, 6) = i
  ActiveSheet.Cells(n, 7) = "="
  ActiveSheet.Cells(n, 8).Value = c
  n = n + 2
next i
End Sub

关于vba - 在VBA中交替打印,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5389520/

10-10 02:49