Excel精英培训网

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

[已解决]求个简单的vba

[复制链接]
发表于 2012-5-24 12:42 | 显示全部楼层 |阅读模式
Book1.rar (17.88 KB, 下载次数: 7)
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2012-5-24 12:56 | 显示全部楼层    本楼为最佳答案   
  1. Sub test()
  2.     Dim ar, s
  3.     Dim i As Integer, j As Integer
  4.     s = Range("a9")
  5.     ar = Range("d11").CurrentRegion
  6.     For j = 1 To UBound(ar, 2)
  7.         For i = 1 To UBound(ar)
  8.             If ar(i, j) - s = 0 Then
  9.                 Cells(2, j + 3).NumberFormatLocal = "@"
  10.                 Cells(2, j + 3) = ar(i, j)
  11.                 Exit For
  12.             End If
  13.         Next
  14.     Next
  15. End Sub
复制代码
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-11 03:47 , Processed in 0.228441 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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