lzth.net
当前位置:首页 >> 怎么能把ExCEl中某个单元格里的数据读入VB的tExtBox中 >>

怎么能把ExCEl中某个单元格里的数据读入VB的tExtBox中

Dim a As IntegerDim xlApp As Excel.applicationDim xlBook As Excel.WorkbookDim xlSheet As Excel.WorksheetPrivate Sub Form_Load()Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象Set xlBook = xlApp.Workbooks.Open("

在工程中引用Microsoft Excel 14.0 Object Library对象(我的是EXCEL2010,版本号14)Set ex = CreateObject("excel.application")Set exwBook = ex.Workbooks.Open(CommonDialog1.FileName)Set exSheet1 = exwBook.Worksheets(1) '按表序text1.text = exSheet1.Range("C" & 2) '第三列 第二行

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

private sub commandbutton1_click()workbooks.open filename:=thisworkbook.path & "\" & "abc.xls"range("a65500").end(xlup).offset(1, 0) = me.textbox1range("b65500").end(xlup).offset(1, 0) = me.textbox2range("c65500").end(xlup).

首先你需要把文本框text1的Multiline属性设置为true,这样就可以换行了,点击按钮出现对话框,然后选择文件打开,读入它里边的内容 Private Sub Command1_Click() With CommonDialog1.DialogTitle = "打开".FileName = "" '打开当前工

textbox1.text=activesheet.activecell.value

'要在VB中操作Excel,需要引用Excel对象模型'方法,在菜单里选择[工程] -- [引用],在窗口里勾选 Microsoft Excel XX.X Object Library'其中,XX.X取决于你安装的Office的版本号'在你的显示按钮中加入以下代码.'注:"地址"中加入你的excel文

me.textbox1.text=thisworkbook.worksheets("sheet1").cells(1,1)例如表名为sheet1,单元格为a1.textbox为textbox1

亲 直接等于,不行的话用个offset函数,再直接等于

sheets("Sheet2").range("b3")=textbox ---------------------- 比如这样,你在sheet1放了一文本框,和一按钮.你在文本框输入内容,然后按按钮,文本框的值便赋到Sheet2的B3单元格中去.你在按钮的CLICK事件下写入代码 Sheets("Sheet2").Range("B3") = TextBox1 即可也

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