Vba 查询以检索access上的某些单元格

Vba 查询以检索access上的某些单元格,vba,excel,Vba,Excel,我需要为Excel手册创建一个查询,当激活工作表时,该查询将: 查询书中的所有表格,但有几个例外 从每张图纸中检索三个单元格的值 从第4行开始,将这些值发布到三个相关列 目前,我正在考虑从以前的工作中窃取某种数组类型的查询,大致如下: dim ws as worksheet dim arrsheets as variant dim strsheets as string for each ws in activeworkbook.sheets if ws.index > 1 and no

我需要为Excel手册创建一个查询,当激活工作表时,该查询将:

查询书中的所有表格,但有几个例外 从每张图纸中检索三个单元格的值 从第4行开始,将这些值发布到三个相关列

目前,我正在考虑从以前的工作中窃取某种数组类型的查询,大致如下:

dim ws as worksheet
dim arrsheets as variant
dim strsheets as string

for each ws in activeworkbook.sheets
if ws.index > 1 and not ws.name like "BETA*" (( and herein lies the first hurdle, I need to add some other exceptions?))
then
sheet.lmdtmonitor(a4)=ws.sheet(b1)
sheet.lmdtmonitor(b4)=ws.sheet(f1)
sheet.lmdtmonitor(c4)=ws.sheet(f2)

然后让它循环直到结束,上面的a4/b4/c4增加到每张纸上的a5>a6>a7等。

我添加了代码,以帮助您根据需要逐步浏览每张纸,选择大小写-但不确定您想对3个单元格做什么。一旦我知道更多,我会更新我的答案

'CORRELATIVE:

'1. so related that each implies or complements the other.
'2. being in correlation; mutually related.
'3. Grammar. answering to or complementing one another and regularly used in association, as either and or, not only and but.
'4. Biology. (of a typical structure of an organism) found in correlation with another.

'.... please explain further as you're code doesn't help here.

'Sheet.lmdtmonitor(a4) = ws.Sheet(b1)
'Sheet.lmdtmonitor(b4) = ws.Sheet(f1)
'Sheet.lmdtmonitor(c4) = ws.Sheet(f2)

Sub Test()

    Dim ws As Worksheet

    'Worksheets will ignore Chart & Macro sheets.
    For Each ws In ThisWorkbook.Worksheets
        Select Case ws.Name
            Case "ALPHA*", "BETA*"
                'Do nothing, we're ignoring these sheets.
            Case Else
                'Do your correlative stuff with these sheets.

        End Select
    Next ws

End Sub
分类:

Private Sub Worksheet_Activate()
将ws设置为工作表

将最后一行设置为整数 最后一行=4

For Each ws In ThisWorkbook.Worksheets
    Select Case ws.Name
        Case "FRONT PAGE", "ZON-DOCS", "LMDT Monitor", "Stonegate New World"
            'Do nothing, we're ignoring these sheets
        Case Else
            'Primary: Extract Estate Name from "CurrentSheet.B1" to "LMDT Monitor".ColumnB(starting at Row 4)
            Cells(Lastrow, 2).Value = ws.Cells(1, 2)
            'Primary: Extract Last Modified Time from F1 to monitor sheet Column C
            Cells(Lastrow, 3).Value = ws.Cells(1, 6)
            'Primary: Extract Modified By from F2 to monitor sheet Column D
            Cells(Lastrow, 4).Value = ws.Cells(2, 6)
            'Secondary: Insert Sheet# into Column A
            Cells(Lastrow, 1).Value = ws.CodeName
               Lastrow = Lastrow + 1
    End Select
 Next ws

End Sub

嗨,很抱歉没有尽快回复您。从您离开的地方继续—脚本澄清是否需要注意工作表后—然后需要将当前选定工作表中3个单元格的内容复制到主工作表中。举个例子,如果我有10张额外的纸,除了那些被排除在外的。我需要脚本将数据从第一个附加工作表的3个单元格复制到监视器工作表的第一个空行,然后移动到下一个附加工作表。完成后,主工作表将有3列数据。