Excel VBA - Loop to insert formulas

后端 未结 1 897
借酒劲吻你
借酒劲吻你 2020-12-22 07:57

I\'ve come across a worksheet full of formulas mistakes. The project itself its very repetitive so I decided to write some simple VBA code in order to save me some time.

1条回答
  •  暖寄归人
    2020-12-22 08:29

    Your formula is using the semi-colon that your system has set for the list separator in the regional settings. VBA sets the Range .Formula property with a comma regardless of the regional settings but does have a Range .FormulaLocal property that will use the regional settings.

        Range("D73").Formula = "=SEERRO(SOMARPRODUTO('RD - " & i & "'!D266:D268, 'RD - " & i & "'!E266:E268)/SOMA('RD - " & i & "'!D266:D268), 0)"
        Range("D73").FormulaLocal = "=SEERRO(SOMARPRODUTO('RD - " & i & "'!D266:D268; 'RD - " & i & "'!E266:E268)/SOMA('RD - " & i & "'!D266:D268); 0)"
    

    Switch your formula to commas or use the .FormulaLocal property.

    0 讨论(0)
提交回复
热议问题