首先需要知道你要引用的資料在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中的位置,然後在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
資料較多,且有規律可循時,請使用迴圈語句