【问题标题】:Finding strings and operating with cells in big size excel page在大尺寸excel页面中查找字符串并使用单元格进行操作
【发布时间】:2016-07-11 15:22:46
【问题描述】:

我正在处理一个大数据 Excel 页面(我们称之为页面 P.Source),我需要使用指针以非常具体的方式管理字符串。

我需要在 整个范围 A:A 的列中查看字符串的所有出现,并为每个出现检测执行以下操作:

"String detected in Ax cell" (x is the number of cell)
-> Set the pointer to A(x-3) cell and copy this value to other page (P.Other) into the cell A1.
-> Set the pointer to B(x-3) cell and copy this value to other page (P.Other) into the cell B1.

试图通过使用通用函数作为 .Find 通过循环来解决这个问题,但我遇到了问题。

我希望有人可以指导我使用一些功能或操作方法来解决问题,因为我对 VBA 不是很熟悉。

非常感谢。


编辑:

完成评论

加里的学生

我想做的是:

以此为P。来源:

我想要的结果是P.Other中的如下(以“幸福”为字符串):

即复制A(2-1)、B(2-1)和D(2-1)的文本,因为它已经检测到A2中的第一个happines,然后复制A(7-1)的文本) , B (7-1) 和 D (7-1) 因为它检测到了 A7 中的第二个幸福。

再次感谢。

【问题讨论】:

    标签: string excel vba cell


    【解决方案1】:

    假设我们有如下数据:

    我们想要的字符串是“幸福”。运行这个宏:

    Sub Macro2()
        Range("A:B").Select
        Selection.AutoFilter
        ActiveSheet.Range("$A:$B").AutoFilter Field:=1, Criteria1:= _
            "=*happiness*", Operator:=xlAnd
        Selection.Copy
        Sheets("P.Other").Select
        Range("A1").Select
        ActiveSheet.Paste
    End Sub
    

    会产生这个:

    在工作表中P.Other

    请注意:

    这来自宏记录器。

    【讨论】:

    • 这看起来很有趣。稍作修改,我认为这可能足以满足我的目的。你能帮我修改一下我所说的吗?请阅读我在 OP 中的编辑!
    【解决方案2】:

    你可以试试 Like 运算符 (小例子)

    For Each c In [A:A] If c.Font.Name Like "Sample*" Then c.Font.Name = "Times New Roman" End If Next
    

    Like Operator.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-21
      • 2020-01-14
      • 2021-02-11
      • 1970-01-01
      • 2012-06-09
      • 1970-01-01
      • 2018-07-23
      • 2020-05-30
      相关资源
      最近更新 更多