excel vba中的现有公式 [英] present formula in excel vba

查看:100
本文介绍了excel vba中的现有公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在vba宏中实现下面的excel公式,但它不起作用,请建议我正确的方法。

我的问题是我试图找到相同列中的重复条目并标记它是重复的,但不满足条件。

如何使用这个公式制作正确的vba条件?

公式为

 = IF(ISERROR(MATCH(C2,C $ 2:C $ 16, 0 )),   重复



和我在vb中的条件如下:

 如果 WorksheetFunction.IsError(WorksheetFunction.Match(表格( 1 )。单元格(cnt,colCnt),表格( 1 )。范围(  C2:C& lastRow),< span class =code-digit> 0 ))然后 



这里,cnt初始化为2,lastrow是当前列中的总行数

建议我是正确的方法

解决方案

2:C


16, 0 )), 复制



和我在vb中的条件如下:

 如果 WorksheetFunction.IsError(WorksheetFunction.Match(Sheets( 1 ) )。细胞(cnt,colCnt),表格( 1 )。范围(  C2:C& lastRow), 0 ))然后 



这里,cnt初始化为2,lastrow是当前列中的总行数

建议我正确的方法


如果要将公式插入 C2 单元格,试试这个:

表格( 1  ).Range(  C2)。公式=    = IF(ISERROR(MATCH(C& cnt&  ,C 

I am trying to implement below excel formula in vba macro but it's not working,please suggest me right way.
My problem is that I'm trying to find duplicate entry in same column and mark it as duplicate,but it not satisfy the condition.
How to make correct vba condition using this formula?
The formula is

=IF(ISERROR(MATCH(C2,C$2:C$16,0)),"","Duplicate")


and my condition in vb is given below

If WorksheetFunction.IsError(WorksheetFunction.Match(Sheets(1).Cells(cnt, colCnt), Sheets(1).Range("C2:C" & lastRow), 0)) Then


Here,cnt initialize to 2 and lastrow is total rows in current column
Suggest me the right way to do it

解决方案

2:C


16,0)),"","Duplicate")


and my condition in vb is given below

If WorksheetFunction.IsError(WorksheetFunction.Match(Sheets(1).Cells(cnt, colCnt), Sheets(1).Range("C2:C" & lastRow), 0)) Then


Here,cnt initialize to 2 and lastrow is total rows in current column
Suggest me the right way to do it


If you want to insert formula into C2 cell, try this:

Sheets(1).Range("C2").Formula = "=IF(ISERROR(MATCH(C" & cnt & ",C


这篇关于excel vba中的现有公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆