|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
我觉得你的代码是正确的,但就是不知道为什么不行,好像和Cells 的用法有关。
思路也没问题,用你的思路回避了Cells 表示法,直接用Range 调试成功。- Sub zjsj()
- ' Dim wb As Workbook, x As Integer, y As String
- '
- ' Set wb = Workbooks.Open(ThisWorkbook.Path & "\a.xls")
- ' For x = 1 To wb.Sheets.Count
- '
- ' wb.Sheets(x).UsedRange.Offset(1, 0).Copy ThisWorkbook.Sheets _
- ' ("第2题").Cells(Range("a65536").End(xlUp).Row, "a").Offset(1, 0)
- ' Next
- ' wb.Close
- Dim wb As Workbook, x As Integer, sh As Worksheet
- Set wb = Workbooks.Open(ThisWorkbook.Path & "\a.xls")
- Set sh = ThisWorkbook.Sheets("第2题")
- For x = 1 To wb.Sheets.Count
-
- wb.Sheets(x).Range("a2: d" & wb.Sheets(x).Range("a1000").End(xlUp).Row) _
- .Copy sh.Range("a1000").End(xlUp).Offset(1, 0)
- Next
- wb.Close
- Set wb = Nothing
- Set sh = Nothing
- End Sub
复制代码 |
|