|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Set SH0 = Worksheets("基础数据")
- SH0.Range("B2:DZ1048576").ClearContents
- FileArr = FileAllArr(ThisWorkbook.Path, "*.xls?", ThisWorkbook.Name, True, False)
- For i = 0 To UBound(FileArr)
-
- Set WB = Workbooks.Open(FileArr(i)) '//打开工作簿
- Set SHX = WB.Sheets(1)
- For IROW = 2 To SH0.Range("A1048576").End(3).Row '//查找日期
- Set C = SHX.Range("A:A").Find(Format(SH0.Cells(IROW, 1), "yyyy-MM-dd"), , LOOKAT:=xlWhole) '//基础表:注意日期的格式
- ' Set C = SHX.Range("A:A").Find(SH0.Cells(IROW, 1), , LOOKAT:=xlWhole) '//或是设置成文本格式
- If Not C Is Nothing Then '//如果有此日期
- strName = GetPathFromFileName(FileArr(i)) '//工作簿名
- Select Case strName
- Rem 七种粘贴方式
- Case "1" '//工作簿名
- RangeA = "B" & IROW '//汇总表粘贴位置
- RangeAddress = "B" & C.Row & ":AE" & C.Row '//复制每日取数中的:位置
- Case "2"
- RangeA = "AF" & IROW
- RangeAddress = "B" & C.Row & ":P" & C.Row
- Case "3"
- RangeA = "AU" & IROW
- RangeAddress = "B" & C.Row & ":AE" & C.Row
- Case "4"
- RangeA = "BY" & IROW
- RangeAddress = "B" & C.Row & ":AE" & C.Row
- Case "5"
- RangeA = "DC" & IROW
- RangeAddress = "B" & C.Row & ":D" & C.Row
- Case "6"
- RangeA = "DF" & IROW
- RangeAddress = "B" & C.Row & ":H" & C.Row
- Case "7"
- RangeA = "DM" & IROW
- RangeAddress = "B" & C.Row & ":E" & C.Row
- End Select
-
- SHX.Range(RangeAddress).Copy SH0.Range(RangeA) '//复制数据
- End If
- Next IROW
-
- WB.Close False '//
- Next
复制代码 |
|