读取Excel,放到vb的变量里
读取excel网上代码好多的,我也可以给你一个示例
使用以下代码方式写或读Excel表格。
Private Sub Command1_Click()
Dim xlapp As Object
Dim xlBook As Object
Dim xlSheet As Object
Dim a As String
Dim b As String
Set xlapp = CreateObject("excel.application")
xlapp.Visible = True
Set xlBook = xlapp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
a = "vb操作excel"
xlSheet.Cells(1, 1) = a
Dim C
C = xlSheet.UsedRange.Rows.Count
b = xlSheet.Cells(1, 1)
Debug.Print b
也可使用数据控件连接Excel表格来获取数据。