我需要为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等。
答案 0 :(得分:0)
排序:)
Private Sub Worksheet_Activate()
Dim ws As Worksheet
Dim Lastrow As Integer Lastrow = 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