qzgx.net
当前位置:首页 >> vB读取ExCEl单元格 >>

vB读取ExCEl单元格

Private Sub Command1_Click() Dim A As Integer Dim scxls As New excel.Application Dim scbook As excel.Workbook Dim scsheet As excel.Worksheet Set scxls = CreateObject("excel.application") '创建EXCEL对象 scxls.DisplayAlerts = False

先把excel文件放到指定的路径 然后逐行读取 最后赋值到list中

range("xx").value或者 cells(x,x).value

把 If xlSheet.Cells(i, 1) > 0 Then 改为 If Val(xlSheet.Cells(i, 1)) > 0 试试

Private Sub Command1_Click() Dim xl As Excel.Application Dim xlbook As Excel.Workbook Set xl = CreateObject("excel.application") xl.Visible = False Dim st As Excel.Worksheet Set xlbook = xl.Workbooks.Open(App.Path & "\date.xlsx") Set

第一种方法,直接打开excel,这样速度不如第二种方法快.1、先在"工程"--"引用"中选中"microsoft excel x..0 object library"2、 dim xlapp as new excel.application dim xlbook as excel.workbook dim xlsheet as excel.worksheet set xlbook

sub test() Set xlsApp=GetObject(,"excel.application") if xlsApp Is Nothing then exit sub msgbox xlsApp.ActiveCell.Value end sub 用Set xlsApp=GetObject(,"excel.application")可以获得当前打开的excel程序 可以用xlsApp.workbooks(i)

Dim xlApp As Excel.ApplicationDim xlBook As Excel.WorkbookDim xlSheet As Excel.WorksheetPrivate Function ReadA2() As StringSet xlApp = CreateObject("Excel.Application")Set xlBook = xlApp.Workbooks.Open("c:\12.xls")Set xlSheet = xlBook.Worksheets("Sheet1")你想要的 = xlSheet.cells(2, 1) '或者加上.ValueEnd Function

错误不少啊?用这个吧!Dim a(101) As String Dim i As Integer Dim b As Double Dim ExcelApp As Excel.Application Dim ExcelworkBook As Excel.Workbook Dim ExcelSheet As Excel.Worksheet Set ExcelApp = CreateObject("Excel.Application

xlsht1.range(cells(r, 15), cells(r, 20)).select '选中要合并的单元格selection.merge '合并

网站首页 | 网站地图
All rights reserved Powered by www.qzgx.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com