求助,在EXCEL表中用VB实现下面的功能.

来源:百度知道 编辑:UC知道 时间:2024/05/22 14:30:23
我现在有BOOK1,BOOK2,BOOK3三个EXCEL表,我想让BOOK3表中自动显示BOOK1和BOOK2里的内容,而且是按顺序排列下来的,其中BOOK1和BOOK2里的内容是会随时添加和删除的,不知道这个用VB怎么写呢?
是把BOOK1里的SHEET1和BOOK2里的SHEET1的内容显示在BOOK3的SHEET1的里面,是从上到下的顺序.

'工程中添加引用Microsoft Excel 9.0 Object Library

Private Sub Command1_Click()

Dim xlApp As Excel.Application

Dim xlBookA As Excel.Workbook
Dim xlBookB As Excel.Workbook
Dim xlBookC As Excel.Workbook

Dim xlSheetA As Excel.Worksheet
Dim xlSheetB As Excel.Worksheet
Dim xlSheetC As Excel.Worksheet

Dim xlRange As Excel.Range

Dim strPathA As String
Dim strPathB As String
Dim strPathC As String

strPathA = "C:\BOOK1.xls"
strPathB = "C:\BOOK2.xls"
strPathC = "C:\BOOK3.xls"

If Dir(strPathC) <> "" Then Kill strPathC

Set xlApp = CreateObject("EXCEL.Application")

xlApp.Visible = True
xlApp.WindowState = xlMaximized

Set xlBookA = xlApp.Workbooks.Open(strPathA)
Set xlBookB = xlApp.Workbooks.Open(strPathB)
Set xlBookC = xlApp.Workbooks.Add()

Set xlSh