我有此查找的查询,它寻找一个"),然后将其移动直到不靠近任何数据。
Sub SeekParen()
Dim c As Range, wheree As Range
Dim whatt As String
Dim TotalCycle As Long, CounterCycle As Long
whatt = ")"
Set c = Range("A1:A10")
Set wheree = c.Find(what:=whatt, after:=c(1)).Offset(0, 1)
TotalCycle = Application.WorksheetFunction.CountIf(c, whatt)
For CounterCycle = 1 To TotalCycle
If wheree.Value <> "" Then
Range("A2").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Set wheree = c.Find(what:=whatt, after:=c(wheree.Row)).Offset(0, 1)
Else
Exit For
End If
Next CounterCycle
End Sub
我也有一个主查询,可以通过所有工作表运行每个查询。
Sub MasterTransformationMacro()
'Dim wb As Workbook
'Set wb = Workbooks("Book2.xlsm")
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
Call SeekParen(ws)
Call SeekParen(ws)
Call Move(ws)
Call DoTrim(ws)
Call CopyA(ws)
Call ReplaceDelimit(ws)
Call Split(ws)
Call DeleteAllEmptyCRows(ws)
Call DeleteC(ws)
Call Formuoli(ws)
Call InsertSystemPath(ws)
Next
End Sub
我只不知道如何编辑Seekparen来适合Mastermacro。任何帮助将不胜感激。
如果将工作表引用到该函数,例如此
Call SeekParen(ws)
和修改SeekParen
接收它,例如So
Sub SeekParen(ws as Worksheet)
然后,您应该能够将经过的工作表引用附加到SeekParen
主体中的每条相关行,例如So
Dim c As Range, wheree As Range
Dim whatt As String
Dim TotalCycle As Long, CounterCycle As Long
whatt = ")"
Set c = ws.Range("A1:A10")
Set wheree = c.Find(what:=whatt, after:=c(1)).Offset(0, 1)
TotalCycle = Application.WorksheetFunction.CountIf(c, whatt)
For CounterCycle = 1 To TotalCycle
If wheree.Value <> "" Then
ws.Range("A2").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Set wheree = c.Find(what:=whatt, after:=c(wheree.Row)).Offset(0, 1)
Else
Exit For
End If
Next CounterCycle