怎样用vb提取Excel中想要的数据
展开全部
首先需要知道你要引用的数据在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
数据较多,且有规律可循时,请使用循环语句
然后打开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
数据较多,且有规律可循时,请使用循环语句
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |