Excel精英培训网

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

[已解决]求助/VB根据A列查找

[复制链接]
发表于 2012-8-27 01:12 | 显示全部楼层 |阅读模式


                                           求助/VB根据A列查找




                                     求助查找.rar (9.04 KB, 下载次数: 31)
发表于 2012-8-27 01:41 | 显示全部楼层    本楼为最佳答案   
  1. Sub s1()
  2.     Dim lastr&
  3.     Dim c&
  4.     Dim r&
  5.     Dim i
  6.    
  7.     lastr = Range("a65535").End(xlUp).Row
  8.     For i = 7 To lastr
  9.         With Sheets("价格表")
  10.             c = Application.WorksheetFunction.CountIf(.[a:a], Cells(i, 1).Value)
  11.             If c > 0 Then
  12.                 r = .[a:a].Find(Cells(i, 1), , , , , xlNext).Row
  13.                 Cells(i, 1).Resize(1, 9).Value = .Cells(r, 1).Resize(1, 9).Value
  14.             End If
  15.         End With
  16.     Next
  17. End Sub
复制代码
回复

使用道具 举报

 楼主| 发表于 2012-8-27 01:48 | 显示全部楼层
hwc2ycy 发表于 2012-8-27 01:41

                       

                                                                   谢谢    hwc2ycy
回复

使用道具 举报

发表于 2012-8-27 01:55 | 显示全部楼层
本帖最后由 hwc2ycy 于 2012-8-27 02:02 编辑

刚测试发现FIND参数用误。
  1. Sub s1()
  2.     Dim lastr&
  3.     Dim c&
  4.     Dim r&
  5.     Dim i&
  6.    
  7.     Application.ScreenUpdating = False
  8.    
  9.     lastr = Range("a65535").End(xlUp).Row
  10.     For i = 7 To lastr
  11.         With Sheets("价格表")
  12.             c = Application.WorksheetFunction.CountIf(.[a:a], Cells(i, 1).Value)
  13.             If c > 0 Then
  14.                 r = .[a:a].Find(Cells(i, 1), , , xlWhole, , xlNext).Row
  15.                 Cells(i, 1).Resize(1, 9).Value = .Cells(r, 1).Resize(1, 9).Value
  16.             End If
  17.         End With
  18.     Next
  19. End Sub
复制代码
回复

使用道具 举报

发表于 2012-8-27 01:56 | 显示全部楼层
byeyes 发表于 2012-8-27 01:48
谢谢 ...

用我刚发的新的,上面的有点小暇渍。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-20 14:09 , Processed in 0.329043 second(s), 13 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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