Excel精英培训网

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

[已解决]高手请帮忙

[复制链接]
发表于 2011-5-25 13:46 | 显示全部楼层 |阅读模式


cf1b9d166aefae0df3de3215.png
我是要在B2单元格中套入自定义公式,如果A2中有包含D例的区域名称就将其区域名称填 写出来


Function FuckCounta(店名 As Range) As String
Dim x%, n As Long
x = Application.WorksheetFunction.CountA(Columns("D"))
For n = 1 To x
If Application.WorksheetFunction.Find(cell(4, n), 店名) >= 1 Then 客户 = cell(4, n)
n = n + 1
Next
End Function
请帮我看一下这个编程,每次都说编译错误 子过程或函数未定义
最佳答案
2011-5-25 14:10
  1. Function FuckCounta(Rng As Range) As String
  2. Dim arr
  3. Dim i As Long
  4. arr = Range("D2:D" & Range("D65536").End(xlUp).Row)
  5. For i = 1 To UBound(arr, 1)
  6. If InStr(Rng, arr(i, 1)) Then
  7. FuckCounta = IIf(FuckCounta = "", arr(i, 1), FuckCounta & "," & arr(i, 1))
  8. End If
  9. Next i
  10. End Function
复制代码

发表于 2011-5-25 14:04 | 显示全部楼层
cell少加一个s 店名没定义 如果包含多个怎么显示
回复

使用道具 举报

发表于 2011-5-25 14:07 | 显示全部楼层
本帖最后由 mxg825 于 2011-5-25 14:10 编辑

Function FuckCounta(店名 As Range) As String
Dim x%, n As Long
x = Application.WorksheetFunction.CountA(Columns("D"))'这是不是07版以上才有的函数?
FuckCounta = “”
For n = 1 To x
If Application.WorksheetFunction.Find(cells(4, n), 店名) >= 1 Then
   FuckCounta = cells(4, n)
   Exit For
Next
End Function
回复

使用道具 举报

发表于 2011-5-25 14:10 | 显示全部楼层    本楼为最佳答案   
  1. Function FuckCounta(Rng As Range) As String
  2. Dim arr
  3. Dim i As Long
  4. arr = Range("D2:D" & Range("D65536").End(xlUp).Row)
  5. For i = 1 To UBound(arr, 1)
  6. If InStr(Rng, arr(i, 1)) Then
  7. FuckCounta = IIf(FuckCounta = "", arr(i, 1), FuckCounta & "," & arr(i, 1))
  8. End If
  9. Next i
  10. End Function
复制代码

回复

使用道具 举报

 楼主| 发表于 2011-5-27 11:02 | 显示全部楼层
回复 搁浅2008 的帖子

非常感谢,我没想到版主会亲自回复!!
回复

使用道具 举报

 楼主| 发表于 2011-5-27 11:06 | 显示全部楼层
再次感谢版主!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-14 13:45 , Processed in 0.257668 second(s), 9 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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