我对使用excel还是陌生的,我没有编码经验,所以我真的不知道该怎么做。我有一个宏集,可以从过滤的列表中收集数据,并将其放入另一个工作簿中。我想知道是否可以在VBA中编写一个循环,以通过每个过滤器重复一次此宏。
我没有尝试任何事情,因为我不确定在编码时该怎么做。我环顾了互联网,找不到真正有用的东西。这是我使用的宏。最后一个宏是我需要循环的宏。它只是一个宏,它运行前面列出的所有其他宏。
Sub z()
'
' z Macro
'
' Keyboard Shortcut: Ctrl+Shift+Z
'
Windows("Fulton Morning.xlsx").Activate
Selection.Copy
Windows("Fulton Cleaned Data-Morning.xlsx").Activate
ActiveSheet.Paste
End Sub
Sub x()
'
' x Macro
'
' Keyboard Shortcut: Ctrl+Shift+X
'
Windows("Fulton Morning.xlsx").Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
ActiveSheet.Paste
Windows("Fulton Cleaned Data-Morning.xlsx").Activate
ActiveCell.Offset(0, 1).Range("A1").Select
End Sub
Sub cc()
'
' cc Macro
'
' Keyboard Shortcut: Ctrl+Shift+C
'
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=AVERAGE('[Fulton Morning.xlsx]Sheet1'!C1)"
End Sub
Sub v()
'
' v Macro
'
' Keyboard Shortcut: Ctrl+Shift+V
'
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("Fulton Morning.xlsx").Activate
Application.CutCopyMode = False
Selection.ClearContents
Windows("Fulton Cleaned Data-Morning.xlsx").Activate
ActiveCell.Offset(0, 1).Range("A1").Select
End Sub
Sub b()
'
' b Macro
'
' Keyboard Shortcut: Ctrl+Shift+B
'
Windows("Fulton Morning.xlsx").Activate
Sheets("Fulton-ATL").Select
ActiveCell.Offset(0, -1).Range("A1").Select
Selection.Copy
Windows("Fulton Cleaned Data-Morning.xlsx").Activate
ActiveSheet.Paste
End Sub
Sub done()
'
' done Macro
'
' Keyboard Shortcut: Ctrl+Shift+A
'
Application.Run "PERSONAL.XLSB!z"
Windows("Fulton Morning.xlsx").Activate
ActiveCell.Offset(0, 6).Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Application.Run "PERSONAL.XLSB!x"
Application.Run "PERSONAL.XLSB!cc"
Application.Run "PERSONAL.XLSB!v"
Application.Run "PERSONAL.XLSB!b"
End Sub
Sub Macro7()
'
' Macro7 Macro
'
' Keyboard Shortcut: Ctrl+Shift+D
'
ActiveCell.Offset(1, -2).Range("A1").Select
Windows("Fulton Morning.xlsx").Activate
Windows("Fulton Cleaned Data-Morning.xlsx").Activate
End Sub
Sub NewDone()
'
' NewDone Macro
'
' Keyboard Shortcut: Ctrl+Shift+A
'
Application.Run "PERSONAL.XLSB!done"
Application.Run "PERSONAL.XLSB!Macro7"
End Sub