谁知道 Cells(c,1).value = i这个命令是中文描述是什么,啥意思?
问题描述:
谁知道 Cells(c,1).value = i这个命令是中文描述是什么,啥意思?
原程序是:
Sub DoIt()
c = 0
For i = 1 To 9
For j = i + 1 To 10
For k = j + 1 To 11
If 2 * j i + k Then
c = c + 1
Cells(c,1).value = i
Cells(c,2).value = j
Cells(c,3).value = k
End If
Next k
Next j
Next i
End Sub
答
Cells是Excel对象Worksheet的属性,您可以如下例利用Cells属性对单元格赋值:
Private Sub Command1_Click()
Dim xl As Excel.Application
Set xl = New Excel.Application
xl.Visible = True 'make the excel application visible
xl.Workbooks.Add
xl.ActiveWorkbook.Worksheets("Sheet1").Cells(1,1).Value = "hello"
xl.ActiveWorkbook.SaveAs ("d:\book1.xls")
xl.Quit
Set xl = Nothing
End Sub