|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Public Function GetData_D365(ByVal wkb_EachSubFile As Workbook) As Boolean
- Dim myWkb As Workbook
- Dim myCopyToSheet As Worksheet
- Dim wks_SubFileSheet As Worksheet
- Dim iLastRow As Long
- Dim iLoop, jLoop As Long
- Dim iCopyRow_Start, iCopyRow_End As Long
- Dim iCopyToRow As Long
- Dim rngTitle_CopyTo As Range
- Dim rngTitle_CopyFrom As Range
- Dim i, j As Long
- Dim arrTitle_CopyFrom()
- Dim arrTitle_CopyTo()
- Dim iLoopTitle As Long
- '/ load payment information
- GetData_D365 = False
- Set myWkb = ThisWorkbook
- Set myCopyToSheet = myWkb.Worksheets("TemplateSheet")
- Set wks_SubFileSheet = wkb_EachSubFile.ActiveSheet
-
- If Not dic_LoadTitle Is Nothing Then
- dic_LoadTitle.RemoveAll
- End If
- Call GetLoadTitle("D365")
- Erase arrTitle_CopyFrom
- Erase arrTitle_CopyTo
- arrTitle_CopyFrom = dic_LoadTitle.keys
- arrTitle_CopyTo = dic_LoadTitle.Items
-
- With wks_SubFileSheet
- .Range("A:ZZ").EntireColumn.Hidden = False
- .Rows("1:65536").EntireRow.Hidden = False
- .AutoFilterMode = False
- iLastRow = .Cells(.Rows.Count, 2).End(xlUp).Row
- For iLoop = 1 To iLastRow
- If .Cells(iLoop, 2).Value = GetValueByKey("Title_Payment_StartRange") Then
- iCopyRow_Start = iLoop + 1
- For jLoop = iLoop + 1 To iLastRow
- If Trim(.Cells(jLoop, 2).Value) = GetValueByKey("Title_Payment_EndRange") Then
- iCopyRow_End = jLoop - 1
- iLoop = jLoop
- '/ copy process
- iCopyToRow = myCopyToSheet.Range("H1048576").End(xlUp).Row + 1
- If iCopyRow_End - iCopyRow_Start = 0 Then
- '/ copy to output template Sheet
- For iLoopTitle = 0 To UBound(arrTitle_CopyFrom)
- Set rngTitle_CopyTo = myCopyToSheet.Rows("1:1").Find(arrTitle_CopyTo(iLoopTitle), Lookat:=xlWhole)
- If Not rngTitle_CopyTo Is Nothing Then
- Set rngTitle_CopyFrom = .Rows(iCopyRow_Start - 1).Find(arrTitle_CopyFrom(iLoopTitle), Lookat:=xlWhole)
- If Not rngTitle_CopyFrom Is Nothing Then
- .Cells(iCopyRow_End, rngTitle_CopyFrom.Column).Copy myCopyToSheet.Cells(iCopyToRow, rngTitle_CopyTo.Column)
- End If
- End If
- Next
- Exit For
- ElseIf iCopyRow_End - iCopyRow_Start > 0 Then
- '/ copy to output template Sheet
- For iLoopTitle = 0 To UBound(arrTitle_CopyFrom)
- Set rngTitle_CopyTo = myCopyToSheet.Rows("1:1").Find(arrTitle_CopyTo(iLoopTitle), Lookat:=xlWhole)
- If Not rngTitle_CopyTo Is Nothing Then
- Set rngTitle_CopyFrom = .Rows(iCopyRow_Start - 1).Find(arrTitle_CopyFrom(iLoopTitle), Lookat:=xlWhole)
- If Not rngTitle_CopyFrom Is Nothing Then
- .Range(.Cells(iCopyRow_Start, rngTitle_CopyFrom.Column), .Cells(iCopyRow_End, rngTitle_CopyFrom.Column)).Copy myCopyToSheet.Cells(iCopyToRow, rngTitle_CopyTo.Column)
- End If
- End If
- Next
- Exit For
- End If
- End If
- Next
- End If
- Next
- End With
- GetData_D365 = True
- Exit Function
- ErrorHandle:
- GetData_D365 = False
- End Function
复制代码
|
|