发布网友 发布时间:2022-04-21 07:31
共1个回答
热心网友 时间:2022-06-18 17:42
首先需要知道你要引用的数据在Excel中的位置,然后在VB里面引用Excel,
然后打开Excel文件读数据
Dim scxls As Excel.Application
Dim scbook As Excel.Workbook
Dim scsheet As Excel.Worksheet
‘Set scxls = CreateObject("excel.application")
‘Set scbook = scxls.Workbooks.Add
Set scbook = scxls.Workbooks.open("c:\1.xls")
Set scsheet = scbook.Worksheets(1)
‘scsheet.Cells(1, 2) = "1111" ’写入数据
a=scsheet.Cells(1, 2) '读取数据
Set scbook = Nothing
Set scxls = Nothing
‘scxls.Visible = True ’显示Excle
数据较多,且有规律可循时,请使用循环语句