怎样用vb提取Excel中想要的数据

2024-12-03 06:51:23
推荐回答(1个)
回答1:

首先需要知道你要引用的数据在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
数据较多,且有规律可循时,请使用循环语句