问题描述
- vb 把数据输入到excel表中
-
For m = 68 To 80 Step 3
For n = 12.6 To 16.2 Step 1.2
For o = 3.6 To 4.4 Step 0.2
For p = 210 To 275 Step 30
If m <> n And m <> o And m <> p And n <> o And n <> p Then
Print m; n; o; p
End If
Next
Next
Next
Next
怎么把print给换成是输入到excel表
解决方案
两个办法,简单的,这么写:
open "x:path1.csv" for output as #1
For m = 68 To 80 Step 3
For n = 12.6 To 16.2 Step 1.2
For o = 3.6 To 4.4 Step 0.2
For p = 210 To 275 Step 30
If m <> n And m <> o And m <> p And n <> o And n <> p Then
Print #1 m &","& n & "," o & "," p
End If
Next
Next
Next
Next
close #1
虽然这个办法产生的不是真正的excel文件,但是csv文件也可以双击直接在excel打开。
另一个办法是引用Excel的COM组件,用VBA去操作。难度略大,你google下,能看懂,有问题可以问。看不懂我觉得你干脆放弃。我也懒得多说,
解决方案二:
VB中的数据输出到EXCEL中
时间: 2024-10-30 07:08:58