Excel精英培训网

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

[已解决]请问如何用VBA快速填充?

[复制链接]
发表于 2014-4-27 12:37 | 显示全部楼层 |阅读模式
本帖最后由 felix3 于 2014-4-27 13:24 编辑

Book1.rar (3.69 KB, 下载次数: 7)
发表于 2014-4-27 12:52 | 显示全部楼层    本楼为最佳答案   
本帖最后由 冥王 于 2014-6-20 23:17 编辑
  1. Sub demo()
  2.     Dim r%
  3.     r = Cells(Rows.Count, 1).End(xlUp).Row
  4.     Range("B2:B" & r).SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[1]C"
  5.     Range("B2:B" & r) = Range("B2:B" & r).Value
  6. End Sub
复制代码

41756001-VBA定位空值-323775.rar

8.29 KB, 下载次数: 6

回复

使用道具 举报

发表于 2014-4-27 13:09 | 显示全部楼层
  1. Sub test()
  2.     Dim arr, x&
  3.     arr = Range("a1").CurrentRegion
  4.     For x = UBound(arr) To 2 Step -1
  5.         If arr(x - 1, 2) = "" Then
  6.             arr(x - 1, 2) = arr(x, 2)
  7.         End If
  8.     Next x
  9.     With Range("e1")
  10.         .Resize(UBound(arr), 2) = ""
  11.         .Resize(UBound(arr), 2) = arr
  12.     End With
  13. End Sub
复制代码
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-15 11:23 , Processed in 0.269465 second(s), 13 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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