更改存档的所有工作表中的单元格公式 [英] Changing the formula of cell in all the sheets of the archive

查看:118
本文介绍了更改存档的所有工作表中的单元格公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Excel档案,其中包含大约100页我想要写VBA宏,以便每张表单元格A1将包含这个公式:

I have an Excel archive that contains about 100 sheets i want write VBA macro so that cell A1 of each sheet will contain this formula:

=RECHERCHEV(B2;'SUMUP'!B$1:H478;3;FAUX)

这是我的宏

Sub WorksheetLoop()

     ' Declare Current as a worksheet object variable.
     Dim Current As Worksheet

     ' Loop through all of the worksheets in the active workbook.
     For Each Current In Worksheets

     'Change the formula of cell A1 
        Current.Range("A1").Formula ="=RECHERCHEV(B2;'SUMUP'!B$1:H478;3;FAUX)"
     Next
End Sub

我执行这个宏我得到执行'1004'的错误,请注意,SUMUP是我的存档的一张

When i execute this macro i got error of execution '1004', Note that SUMUP is a sheet of my archive

推荐答案

VBA非常EN-US-中心。 Range.Formula属性期望输入为EN-US;您可以使用 Range.FormulaLocal属性,如果要使用非EN-US Office语言包FR-FR区域。

VBA is very EN-US-centric. The Range.Formula property expects input as EN-US; you can use the Range.FormulaLocal property if you want to use the non-EN-US Office language pack FR-FR regionals.

使用下列其中之一:

Current.Range("A1").Formula = "=VLOOKUP(B2,'SUMUP'!B$1:H478, 3, False)"
Current.Range("A1").FormulaLocal = "=RECHERCHEV(B2;'SUMUP'!B$1:H478;3;FAUX)"

Current.Range("A1").FormulaLocal = "=REMPLACER(CELLULE(""filename"";A1);1;TROUVE(""]"";CELLULE(""filename"";A1));"""")"

这篇关于更改存档的所有工作表中的单元格公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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