Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1455|回复: 5

[已解决]历遍工作表移动数据的问题

[复制链接]
发表于 2013-6-24 13:07 | 显示全部楼层 |阅读模式
附件 历遍工作表移动数据附件.rar (283.85 KB, 下载次数: 16)
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2013-6-24 13:23 | 显示全部楼层
是移动到行下面了,还是列的右边。
回复

使用道具 举报

发表于 2013-6-24 13:24 | 显示全部楼层
你说的是移动吧,数据过来后,原有工作表里的数据清除掉,对不?
回复

使用道具 举报

发表于 2013-6-24 13:28 | 显示全部楼层    本楼为最佳答案   
  1. Sub test()

  2.     On Error GoTo ErrorHandler
  3.     With Application
  4.         .ScreenUpdating = False
  5.         .DisplayAlerts = False
  6.         .EnableEvents = False
  7.         .Calculation = xlCalculationManual
  8.     End With
  9.    
  10.     Dim arr
  11.     Dim bSheet As Byte
  12.     For bSheet = 1 To 6
  13.         With Worksheets(CStr(bSheet))
  14.             arr = .Range("a1").CurrentRegion.Columns("a:f").Value
  15.         End With
  16.         With Worksheets("sheet0")
  17.             With .Cells(Rows.Count, 1).End(xlUp).Offset(1)
  18.                 .Resize(UBound(arr), UBound(arr, 2)).Value = arr
  19.             End With
  20.         End With
  21.     Next

  22.     With Application
  23.         .ScreenUpdating = True
  24.         .DisplayAlerts = True
  25.         .EnableEvents = True
  26.         .Calculation = xlCalculationAutomatic
  27.     End With
  28.     MsgBox "合并完成"
  29.     Exit Sub
  30.    
  31. ErrorHandler:
  32.     MsgBox Err.Number & vbCrLf & _
  33.            Err.Description
  34.     With Application
  35.         .ScreenUpdating = True
  36.         .DisplayAlerts = True
  37.         .EnableEvents = True
  38.         .Calculation = xlCalculationAutomatic
  39.     End With

  40. End Sub
复制代码

评分

参与人数 1金币 +1 收起 理由
Dengbb + 1 很给力!

查看全部评分

回复

使用道具 举报

发表于 2013-6-24 13:30 | 显示全部楼层
原有工作表1-6的内容没有清除。
回复

使用道具 举报

 楼主| 发表于 2013-6-24 13:36 | 显示全部楼层
hwc2ycy 发表于 2013-6-24 13:30
原有工作表1-6的内容没有清除。

谢谢老师帮助,试了一下,效果很好。再谢。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-26 21:09 , Processed in 0.382149 second(s), 18 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表